     }
     
     public func perform(wait: Bool = true, block: @escaping ContextClosure) {
-        let context = stack.mainContext!
+        let context = stack.mainContext
         
         if wait {
             context.performAndWait {

    }
    
    public func save(completion: (() -> ())? = nil) {
        guard let context = stack.mainContext else {
            return
        }
        
        save(context: context, completion: completion)
    }
    
    private func save(context: NSManagedObjectContext, completion: (() -> ())? = nil) {

    }
}

private class CoreStack {
    fileprivate let modelName: String
    fileprivate let type: String
    fileprivate let identifier: String
    private let directory: FileManager.SearchPathDirectory
    fileprivate let mergePolicy: NSMergePolicyType
    fileprivate let wipeOnConflict: Bool
    fileprivate var managedObjectModel: NSManagedObjectModel?
    fileprivate var persistentStoreCoordinator: NSPersistentStoreCoordinator {
        fatalError()
    }
    internal var mainContext: NSManagedObjectContext {
        fatalError()
    }
    
    init(modelName: String, type: String = NSSQLiteStoreType, identifier: String, in directory: FileManager.SearchPathDirectory = .documentDirectory, mergePolicy: NSMergePolicyType = .mergeByPropertyObjectTrumpMergePolicyType, wipeOnConflict: Bool) {
        
        self.modelName = modelName
        self.type = type
        self.identifier = identifier
        self.directory = directory
        self.mergePolicy = mergePolicy
        self.wipeOnConflict = wipeOnConflict
    }
    
    fileprivate var databaseFilePath: URL? {
        if type == NSSQLiteStoreType {
            return workingFilesDirectory.appendingPathComponent("\(self.modelName).sqlite")
        } else {
            return nil
        }
    }
    
    private lazy var workingFilesDirectory: URL = {
        let urls = FileManager.default.urls(for: self.directory, in: .userDomainMask)
        let last = urls.last!
        let dbIdentifier = self.identifier + ".db"
