renamed name to aiType, and some tweeking.