Finalized AI module refactoring. Everything works now.