Refactoring to improve code quality metrics