Refactoring and completion