Some refactoring for Sonar issues