improved event emitter, small bug fixes