Many fixes for Windows msvc2008