MSVC compatibility fixes.

40 files changed