Fix most warnings, re-fix MSVC compile error