Fixed critical AI bugs