Fixed code analysis errors

#2501