Factor out some common functions

Events and Signals are very similar, so we can deduplicate a lot of
these functions.