Semantic refactoring