MSVC build and Windows fixes