Forward-port event queue fixes from 5.4 tree.