Fixed MSVC2012 build errors and warnings.