         }
 
         if operations.contains(.insert) {
+            let insertedObjectIDs = Array(remotePrimaryKeysSet.subtracting(localPrimaryKeys))
+
             for fetchedID in insertedObjectIDs {
                 let objectDictionary = remotePrimaryKeysAndChanges[fetchedID]!
                 inserted(objectDictionary)

            remotePrimaryKeysAndChanges[primaryKey] = change
        }

        var intersection = Set(remotePrimaryKeysWithoutNils)
        intersection.formIntersection(Set(localPrimaryKeys))
        let updatedObjectIDs = Array(intersection)

        var deletedObjectIDs = localPrimaryKeys
        deletedObjectIDs = deletedObjectIDs.filter { value in
            !remotePrimaryKeysWithoutNils.contains { $0.isEqual(value) }
        }

        var insertedObjectIDs = remotePrimaryKeysWithoutNils
        insertedObjectIDs = insertedObjectIDs.filter { value in
            !localPrimaryKeys.contains { $0.isEqual(value) }
        }

        if operations.contains(.delete) {
            for fetchedID in deletedObjectIDs {
                let objectID = primaryKeysAndObjectIDs[fetchedID]!
                let object = context.object(with: objectID)

        }

        if operations.contains(.update) {
            let updatedObjectIDs = Array(remotePrimaryKeysSet.intersection(localPrimaryKeysSet))

            for fetchedID in updatedObjectIDs {
                let JSON = remotePrimaryKeysAndChanges[fetchedID]!
                let objectID = primaryKeysAndObjectIDs[fetchedID]!
