Code refactoring to remove complexity and unused methods