Fix some issues found by the Visual Studio 2012 static analyzer.