Minor AI bugfixes and improvements