 
                 DispatchQueue.main.async {
                     // Actually delete previously soft-deleted items from the database
-                    self.performRealmOperations { realm in
-                        deletedFavorites.forEach(realm.delete)
-                        deletedBookmarks.forEach(realm.delete)
+                    let deletedFavoriteObjIDs = deletedFavorites.toArray().map(\.identifier)
+                    let deletedBookmarkObjIDs = deletedBookmarks.toArray().map(\.identifier)
+
+                    self.performRealmOperations { queueRealm in
+                        let favoriteObjs = deletedFavoriteObjIDs.compactMap { queueRealm.object(ofType: Favorite.self, forPrimaryKey: $0) }
+                        let bookmarkObjs = deletedBookmarkObjIDs.compactMap { queueRealm.object(ofType: Bookmark.self, forPrimaryKey: $0) }
+
+                        favoriteObjs.forEach(queueRealm.delete)
+                        bookmarkObjs.forEach(queueRealm.delete)
                     }
                 }
             }

    }

    private func updateDatabaseModelsSystemFieldsAfterUpload(with records: [CKRecord]) {
        performRealmOperations { realm in
            records.forEach { record in
                guard let modelType = realmModel(for: record.recordType) else {
                    os_log("There's no corresponding Realm model type for record type %{public}@",
                           log: log,
                           type: .error,
                           record.recordType)
                    return


        os_log("Will commit %{public}d changed record(s) to the database", log: log, type: .info, records.count)

        performRealmOperations { [weak self] queueRealm in
            guard let self = self else { return }

            records.forEach { record in
                switch record.recordType {
                case RecordTypes.favorite:
                    self.commit(objectType: Favorite.self, with: record, in: queueRealm)
                case RecordTypes.bookmark:
                    self.commit(objectType: Bookmark.self, with: record, in: queueRealm)
                case RecordTypes.sessionProgress:
                    self.commit(objectType: SessionProgress.self, with: record, in: queueRealm)
                default:
                    os_log("Unknown record type %{public}@", log: self.log, type: .fault, record.recordType)
                }
