AI behaviour refactoring