                         before = @pending[i-1]
                         before.buffer = before.buffer.concat @buffer
                         @buffer = []
-                    tag.removeListener 'data', pipe.data
-                    for event in EVENTS
-                        tag.removeListener event, pipe[event]
+                    rmevents.call tag, events
                     if @closed is 'pending'
-                        if @buffer.length
-                            for data in @buffer
-                                @write data
-                            @buffer = []
+                        flush.call this
                         @end()
                     return
             throw new Error("this shouldn't happen D:")

        tag.end.apply tag, arguments if opts.end
        this

    tag.on 'data', pipe.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
        if @pending[0] is tag
            if tag.pending.length
                tag.pending[0].once 'end', on_end

                    @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
