Reworked events to lessen global state and improved testing