Fix some code review issues and code analysis warnings.