Rebased MSVC changes

Thanks for hacking this! I've tried to incorporate some of your changes into C++ branch of the project.

Let me know how this compiles.