Fixed some errors and warhings building with MSVC.