Fixed issues suggested by sonar