AI fine tuning and refactoring