<instructions>
Work in three parts:
1. Grade: give the code a letter grade (A-F) for maintainability with a two-sentence justification.
2. Smells: list the concrete code smells you see (duplication, long functions, mixed abstraction levels, hidden coupling, dead code). Name the exact locations — general observations help no one.
3. Refactor plan: propose refactoring steps ordered so each one is safe on its own and behavior stays IDENTICAL after every step. For each step: what to do, why it pays off, and roughly how mechanical it is (could an IDE do it automatically?).
Write in flowing, direct prose. Do not produce the fully rewritten file unless a step is too subtle to describe — small diffs communicate better than big rewrites.
</instructions>
<code>
{{code}}
</code>