Msvc fixes

With this work, the code should compile cleanly even with msvc compilers.