Fixed issues found with code analysis in VS.