Fix MSVS 2008 build errors and warnings