Moved more AI logic into the AI manager