Refactoring entire codebase to work with dependency injection