Fixed some issues reported by Sonar