Fix some issues reported by sonar.