 
                     let isFullStoreRefresh: Bool = lastSyncTime == nil
                     if isFullStoreRefresh {
-                        let changedAnnouncementIdentifiers = response.announcements.changed.map({ $0.identifier })
-                        let orphanedAnnouncements = existingAnnouncements.map({ $0.identifier }).filter(not(changedAnnouncementIdentifiers.contains))
-                        orphanedAnnouncements.forEach(transaction.deleteAnnouncement)
-
-                        let changedEventIdentifiers = response.events.changed.map({ $0.identifier })
-                        let orphanedEvents = existingEvents.map({ $0.identifier }).filter(not(changedEventIdentifiers.contains))
-                        orphanedEvents.forEach(transaction.deleteEvent)
-
-                        let changedKnowledgeGroupIdentifiers = response.knowledgeGroups.changed.map({ $0.identifier })
-                        let orphanedKnowledgeGroups = existingKnowledgeGroups.map({ $0.identifier }).filter(not(changedKnowledgeGroupIdentifiers.contains))
-                        orphanedKnowledgeGroups.forEach(transaction.deleteKnowledgeGroup)
-
-                        let changedKnowledgeEntryIdentifiers = response.knowledgeEntries.changed.map({ $0.identifier })
-                        let orphanedKnowledgeEntries = existingKnowledgeEntries.map({ $0.identifier }).filter(not(changedKnowledgeEntryIdentifiers.contains))
-                        orphanedKnowledgeEntries.forEach(transaction.deleteKnowledgeEntry)
-
-                        let existingImageIdentifiers = existingImages.map({ $0.identifier })
-                        let changedImageIdentifiers = response.images.changed.map({ $0.identifier })
-                        let orphanedImages = existingImageIdentifiers.filter(not(changedImageIdentifiers.contains))
-                        orphanedImages.forEach(self.imageRepository.deleteEntity)
-
-                        let existingDealerIdentifiers = existingDealers.map({ $0.identifier })
-                        let changedDealerIdentifiers = response.dealers.changed.map({ $0.identifier })
-                        let orphanedDealers = existingDealerIdentifiers.filter(not(changedDealerIdentifiers.contains))
-                        orphanedDealers.forEach(transaction.deleteDealer)
-
-                        let existingMapsIdentifiers = existingMaps.map({ $0.identifier })
-                        let changedMapIdentifiers = response.maps.changed.map({ $0.identifier })
-                        let orphanedMaps = existingMapsIdentifiers.filter(not(changedMapIdentifiers.contains))
-                        orphanedMaps.forEach(transaction.deleteMap)
+                        self.deleteOrphanedEntities(response: response, transaction: transaction)
                     }
-
-                    if response.announcements.removeAllBeforeInsert {
-                        self.announcementsService.models.map({ $0.identifier.rawValue }).forEach(transaction.deleteAnnouncement)
-                    }
-
-                    if response.conferenceDays.removeAllBeforeInsert {
-                        self.schedule.days.map({ $0.identifier }).forEach(transaction.deleteConferenceDay)
-                    }
-
-                    if response.rooms.removeAllBeforeInsert {
-                        self.schedule.rooms.map({ $0.roomIdentifier }).forEach(transaction.deleteRoom)
-                    }
-
-                    if response.tracks.removeAllBeforeInsert {
-                        self.schedule.tracks.map({ $0.trackIdentifier }).forEach(transaction.deleteTrack)
-                    }
-
-                    if response.knowledgeGroups.removeAllBeforeInsert {
-                        self.knowledgeService.models.map({ $0.identifier.rawValue }).forEach(transaction.deleteKnowledgeGroup)
-                    }
-
-                    if response.knowledgeEntries.removeAllBeforeInsert {
-                        self.knowledgeService.models.reduce([], { $0 + $1.entries }).map({ $0.identifier.rawValue }).forEach(transaction.deleteKnowledgeEntry)
-                    }
-
-                    if response.dealers.removeAllBeforeInsert {
-                        existingDealers.map({ $0.identifier }).forEach(transaction.deleteDealer)
-                    }
-
+                    
+                    self.processRemoveAllBeforeInserts(response, transaction: transaction)
                     self.save(characteristics: response, in: transaction)
 
                     response.images.deleted.forEach(transaction.deleteImage)


    private func notifyRefreshStarted() {
        refreshObservers.forEach({ $0.refreshServiceDidBeginRefreshing() })
    }

    private func deleteExistingEntities(imageIdentifiersToDelete: [String],

                self.privateMessagesController.refreshMessages {
                    completionHandler(nil)
                    self.notifyRefreshFinished()
                    self.finishLongRunningTask()
                }
            }
        }
