Finished refactoring AI