Fixed AI access violation bug