fix dangling references to object ids in ai code