         tag.end.apply tag, arguments if opts.end
         this
 
-    tag.on 'data', pipe.data = (data) =>
+    tag.on 'data', events.data = (data) =>
         if @pending[0] is tag
             @write data
         else
             @buffer.push data
 
-    EVENTS.forEach (event) =>
-        tag.on event, pipe[event] = (args...) =>
-            @emit event, args...
-
-    tag.on 'end', on_end = =>
-        tag.removeListener 'end', on_end
+    pipe = (event) =>
+        tag.on event, events[event] = =>
+            @emit event, arguments...
+    pipe event for event in EVENTS
+
+    tag.once 'end', on_end = =>
         if @pending[0] is tag
             if tag.pending.length
                 tag.pending[0].once 'end', on_end

    @emit 'add', tag
    tag.children children, opts if children?
    return tag


sync_tag = ->
    [name, attrs, children, opts] = parse_args arguments...

                    @buffer = @buffer.concat tag.buffer
                    tag.buffer = []
                @pending = @pending.slice(1)
                rmevents.call tag, events
                flush.call this
                if @closed and @pending.length is 0
                    @end()
        else
