Fixes some issues pointed out by sonar.