Fix some major sonar issues