Fix some problems with the AI.