Fix `aei` use-after-free issue