Big AI refactor