Patch refactoring