Fix up waiting for events.