             url: @urls.update
             data: object
             success: (data) -> object.changed = false
-            error: => @errors.push 'Failed to update.'
+            error: =>
+              @errors.push 'Failed to update.'
+              # Check to see if we're done.
+              if @dirty_objects - @errors.length == 0
+                complete_callback()
             complete: ->
-              if --dirty_objects == 0
+              # Check to see if we're done.
+              if @dirty_objects - @errors.length == 0
                 complete_callback()
-            ,
             dataType: 'json'
   # Used to wipe out the in-memory object list with a fresh one from the server.
   reload: (complete_callback) ->

      complete_callback()
      return

    # Sync the in-memory data store to the server.
    sync_error = false
    for object in @objects

            success: (data) =>
              object[@id_attribute] = data.id
              object.changed = false
            error: =>
              @errors.push 'Failed to create.'
              # Check to see if we're done.
              if @dirty_objects - @errors.length == 0
                complete_callback()
            complete: ->
              # Check to see if we're done.
              if @dirty_objects - @errors.length == 0
                complete_callback()
            dataType: 'json'
        else
          # This is a pre-existing object to be updated.
