         var currentContext: NSManagedObjectContext? = self.mainManagedObjectContext
         
         while let c = currentContext {
-            c.performBlock {
+            c.performBlockAndWait {
                 c.reset()
             }
             


    @objc private func backgroundManagedObjectContextDidSave(notification: NSNotification) {
        if let mainContext = self.stack.mainManagedObjectContext {
            mainContext.performBlock {
                mainContext.mergeChangesFromContextDidSaveNotification(notification)
            }
        }
    }
    
    @objc private func persistentStoreCoordinatorStoresWillChange(notification: NSNotification) {
        self.performBlock {
            var error: NSError? = nil
            self.save(&error)
            self.reset()

    }
    
    @objc private func persistentStoreCoordinatorStoresDidChange(notification: NSNotification) {
        self.performBlockAndWait {
            self.reset()
        }
    }
    
    @objc private func persistentStoreDidImportUbiquitousContentChanges(notification: NSNotification) {
        self.performBlockAndWait {
            self.mergeChangesFromContextDidSaveNotification(notification)
        }
    }
