Extract common code for refactorings