         .fail (error) ->
           done error, null
         .done()
+
+        Q.all [controlPromise, lastControlPromise]
+        .then ->
+          done null, []
+        .fail (error) ->
+          done error, null
+        .done()
+
         lastBufferGroupValue = groupValue
     .on 'end', (count) ->
-      if lastBufferGroupValue?
-        buffers[lastBufferGroupValue].finished()
-
-      d.resolve(count)
+      p =
+        if lastBufferGroupValue?
+          buffers[lastBufferGroupValue].finished()
+        else
+          Q(false)
+
+      p
+      .then ->
+        d.resolve count
+      .fail (error) ->
+        d.reject error
+      .done()
     .on 'error',
       (error) -> d.reject(error)
 

        groupValue = if @_mapping.groupColumn? then inObj[@_mapping.groupColumn] else "#{idx}"
        buffer = buffers[groupValue]

        if not buffer?
          buffer = new GroupBuffer()

          if lastBufferGroupValue?
            buffers[lastBufferGroupValue].finished()
          buffers[groupValue] = buffer

          if not @_mapping.groupColumn?
            buffer.finished()

        bufferFirstIdx = buffer.getFirstIndex() or idx
        promise = @_mapping.transformRow requiredGroups, inObj,
          index: if @_includesHeaderRow then idx - 1 else idx
          groupFirstIndex: if @_includesHeaderRow then bufferFirstIdx - 1 else bufferFirstIdx
          groupContext: buffer.getContext()
        .then (val) ->
          done null, []
          val

        buffer.add idx, promise
        .then (convertedPerGroup) =>
          _.each writers, (w) =>
            result = @_convertFromObject(w.newHeaders, _.find(convertedPerGroup, (c) -> c.group is w.group).row)

  getFirstIndex: () ->
    @_firstIdx

  add: (idx, rowFn) ->
    d = Q.defer()

    if not @_firstIdx?
