Fixed compile issues and code analysis warnings.