Patches for windows

Some patches which get it closer to building on windows.