Fix some AI bugs

A few new bugs appeared where the AI would produce #24 errors