Fix various violations reported by sonar that could be trivially fixed.