Fixing various sonar violations