Describe a time when you had to refactor a legacy codebase. What was your strategy for ensuring system stability?