Lots of tweaks to make msvc happy.