bugfixes and AI enhancements