         }
 
         if operations.contains(.insert) {
-            let insertedObjectIDs = Array(remotePrimaryKeysSet.subtracting(localPrimaryKeys))
+            var insertedObjectIDs = remotePrimaryKeysWithoutNils
+            insertedObjectIDs = insertedObjectIDs.filter { value in
+                !localPrimaryKeys.contains { $0.isEqual(value) }
+            }
 
             for fetchedID in insertedObjectIDs {
                 let objectDictionary = remotePrimaryKeysAndChanges[fetchedID]!

            remotePrimaryKeysAndChanges[primaryKey] = change
        }

        let remotePrimaryKeysSet = Set(remotePrimaryKeysWithoutNils)
        let localPrimaryKeysSet = Set(localPrimaryKeys)

        if operations.contains(.delete) {
            let deletedObjectIDs = Array(localPrimaryKeysSet.subtracting(remotePrimaryKeysSet))

            for fetchedID in deletedObjectIDs {
                let objectID = primaryKeysAndObjectIDs[fetchedID]!

        }

        if operations.contains(.update) {
            var intersection = Set(remotePrimaryKeysWithoutNils)
            intersection.formIntersection(Set(localPrimaryKeys))
            let updatedObjectIDs = Array(intersection)

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