Thanks to Bruce Axtens for finding quite a few bugs and memory leaks,
porting to MS Windows, and a number of suggestions.
