Cleanups reported by Sonar and refactorings.