Refactoring, with bugs