Refactor some of the AI code formatting