     opts ?= {}
     return [name, attrs, children, opts]
 
-flush = ->
-    if @buffer.length
-        @write data for data in @buffer
-        @buffer = []
 
 add_tag = (newtag, callback) ->
     return callback?.call(this) unless newtag?

                if tag.pending.length
                    tag.pending[0].once 'end', on_end
                else
                    if tag.buffer.length
                        @buffer = @buffer.concat tag.buffer
                        tag.buffer = []
                    @pending = @pending.slice(1)
                    flush.call this
                    if @closed and @pending.length is 0
                        @end()
            else
                for known, i in @pending
                    if tag is known
                        @pending = @pending.slice(0,i).concat @pending.slice i+1
                        if @buffer.length
                            before = @pending[i-1]
                            before.buffer = before.buffer.concat @buffer
                            @buffer = []
                        if @closed is 'pending'
                            flush.call this
                            @end()
                        return
                throw new Error("this shouldn't happen D:")

        @tag = new_tag
        @$tag = sync_tag

    end: () =>
        if @pending.length
            @closed = 'pending'
