Project Path: {{ absolute_code_path }}

I need your help refactoring this codebase to improve its design, maintainability, and performance. Here are the files involved:

Source Tree:
```
{{ source_tree }}
```

{{#each files}} 
{{#if code}}
`{{path}}`: 

{{code}}

{{/if}}
{{/each}}

Some areas to focus on during the refactoring:

- Adherence to SOLID principles (Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, Dependency Inversion)
- Separation of concerns
- Reducing duplication (DRY - Don't Repeat Yourself)
- Improving naming and code readability
- Enhancing modularity and reusability
- Optimizing performance
- Removing dead or redundant code
- Updating to modern language features or idioms where appropriate
- Ensuring consistent code style and formatting

To refactor effectively:

- Understand the current design and architecture
- Identify pain points, code smells, and areas for improvement
- Break down the refactoring into manageable steps
- Ensure the existing tests pass after each refactoring step
- Look for opportunities to extract reusable functions, classes or modules
- Consider performance implications of design changes
- Keep the code readable and maintainable
- Preserve the original functionality and API contracts

For each major refactoring you propose, please provide:

- File path(s) and line number(s)
- Description of the current code and why it needs refactoring
- Explanation of your proposed changes and their benefits
- Updated code snippets with your refactoring applied

After refactoring, please share the updated codebase. Update any relevant documentation to reflect the changes. Add new unit tests for the refactored code if applicable.
