Moved into here from the main Greenstone source (it is only used for creating distributions, and would be of no interest to anyone else).