slightly modified, this is compiled from the version in greenstone3 cvs, not from an external version