Fixed some issues reported by sonar