Extract duplicated code for management of event trampolines