   # Called internally when processing is finished.
   # Individual callbacks have to be called in the appropriate sections.
   finished: (file, responseText, e) ->
-    @files.processing = without(@files.processing, file)
+    @filesProcessing = without(@filesProcessing, file)
     file.processing = no
+    @processQueue()
     @emit "success", file, responseText, e
     @emit "finished", file, responseText, e # For backwards compatibility
     @emit "complete", file
-    @processQueue()
 
 
   # Called internally when processing is finished.
   # Individual callbacks have to be called in the appropriate sections.
   errorProcessing: (file, message) ->
-    @files.processing = without(@files.processing, file)
+    @filesProcessing = without(@filesProcessing, file)
     file.processing = no
+    @processQueue()
     @emit "error", file, message
     @emit "complete", file
-    @processQueue()
 
 
 



    @files = [] # All files
    @files.queue = [] # The files that still have to be processed
    @files.processing = [] # The files currently processed
    @URL = window.URL ? window.webkitURL
    @setupEventListeners()


  # Goes through the queue and processes files if there aren't too many already.
  processQueue: ->
    parallelUploads = @options.parallelUploads
    processingLength = @filesProcessing.length
    i = processingLength

    while i < parallelUploads
      return  unless @filesQueue.length # Nothing left to process
      @processFile @filesQueue.shift()
      i++


  # Loads the file, then calls finishedLoading()
  processFile: (file) ->
    @filesProcessing.push file
    file.processing = yes

    @emit "processingfile", file
