Compile on vs2010

Various fixes to ensure compilation on Visual Studio 2010.