fix sorting of event queue after introduction of error events.
Also adjust hash implementation to fit the other events.