Refactoring often involves making many localized changes that result in a larger-scale change. If you keep your steps small, and test after each step, you will avoid prolonged debugging.
The Pragmatic Programmer, From Journeyman to Master (Andrew Hunt, David Thomas)