Remove the magic value passed as a flag to event_active.
Fix a memory leak, as well as a possible race condition.