Fixed condition bugs, and refined AI generation.