Add StreamEmitter#safeCast.
Rework the EmitCallback contract. Fix some bugs.