Act as a senior software architect. Refactor the following legacy code to modern best practices without changing public behavior. Explain each refactoring step and why it improves maintainability, performance, or safety. Highlight potential breaking changes and how to avoid them.
Why this works
You force the model to preserve contracts, not just “rewrite prettier code”.
