large refactor for event emitters