Some code refactoring.
Improved #ifdef'ing of Windows-specific code.

Should help anyone wanting to do a port.
Updated readme slightly.