Use EventEmitter instead of hack