Fixed some major issues reported by Sonar.