Refactoring Legacy Code