Fixed critical SonarQube warnings, clean code