Fix some small errors, change some things around for MSVC compatibility