Refactoring ancient code