Fixed compile errors and warnings on MSVC