Fixed a number of sonar violations