AI refactoring