Fixed some issues mentioned by sonar.