Code refactoring + AI continued