 // MARK: Deletion
 extension CoreDataController {
 
-    func delete(object: NSManagedObject, context: NSManagedObjectContext) {
-        logger.logDebug(message: String(format: "[%@] About to delete object <%@> from context <%@>.", instanceType(self), object, context))
+    class func delete(object: NSManagedObject, context: NSManagedObjectContext) {
+        singleton.logger?.logDebug(message: String(format: "[%@] About to delete object <%@> from context <%@>.", classType(self), object, context))
         context.delete(object)
         save(context: context)
     }


class CoreDataController: NSObject {

    private var modelName: String
    private var logger: LogController

    init(_ modelName: String, _ logger: LogController) {
        self.logger = logger
        self.modelName = modelName
        super.init()
    }

    lazy var persistentContainer: NSPersistentContainer = {
        let container = NSPersistentContainer(name: modelName)
        self.logger.logDebug(message: String(format: "[%@] About to load persistent store.", instanceType(self)))
        container.loadPersistentStores(completionHandler: { (storeDescription, error) in
            if let error = error as NSError? {
                self.logger.logError(message: String(format: "[%@] Failed to load persistent store.", instanceType(self)), error: error)
            }
        })
        return container
    }()

}

// MARK: Access
extension CoreDataController {

    func perform(block: ((NSManagedObjectContext) -> Void)) {
        let context = persistentContainer.newBackgroundContext()
        logger.logDebug(message: String(format: "[%@] Vending new context <%@>.", instanceType(self), context))
        block(context)
    }

    func fetch<T>(_ request: NSFetchRequest<T>, context: NSManagedObjectContext) -> [T] {
        var results = [T]()
        do {
            results.append(contentsOf: try context.fetch(request))
        } catch {
          let message = String(format: "[%@] Error executing fetch request <%@> on context <%@>.", instanceType(self), request, context)
            logger.logError(message: message, error: error)
        }
        return results
    }

    func exportData() -> Data {
        let applicationSupportDirectory = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).first! as NSString

        let sqlitePath = applicationSupportDirectory.appendingPathComponent(String(format: "%@.sqlite", Bundle.getAppName()))

        var fileData = [String: NSData]()
        [ sqlitePath, sqliteWALPath, sqliteSHMPath ].forEach {
            guard let data = NSData(contentsOfFile: $0) else {
                singleton.logger?.logWarning(message: String(format: "[%@] No data read from %@.", classType(self), $0))
                return
            }

