A lot of code cleanup.
Now it compiles on CygWin on windows with the -wno-cygwin option.
Readme updated with usage info.