Fixed major Sonar issues