Fixed lots of compilation errors on Windows