Some code refactoring. Fixing Sonar issues.