Fix win32 build; misc changes
Fix build on 64bit windows