Fixed a few compilation errors and warnings on MS VS