Fix issues suggested by sonar