small refactor to clean up how event handlers are registered and removed