Fix issues and code smells detected by Sonarqube - phase 2