Fixed a few issues reported by sonar