Fixed a lot of AI bugs