         
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)) {
             let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
-            let docURL = urls[urls.endIndex-1]
-            let storeURL = docURL.URLByAppendingPathComponent("Brave.sqlite")
-            do {
-                try self.persistentStoreCoordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: storeURL, options: nil)
-            } catch {
-                fatalError("Error migrating store: \(error)")
+            if let docURL = urls.last {
+                let storeURL = docURL.URLByAppendingPathComponent("Brave.sqlite")
+                do {
+                    try self.persistentStoreCoordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: storeURL, options: nil)
+                }
+                catch {
+                    fatalError("Error migrating store: \(error)")
+                }
             }
         }
     }
     
+    // Writes could still be executed on main thread, but recommended to use DataController.write {...}
     static func saveContext() {
         guard let managedObjectContext: NSManagedObjectContext = DataController.singleton.managedObjectContext else {
             return

        if managedObjectContext.hasChanges {
            do {
                try managedObjectContext.save()
            } catch {
                fatalError("Error migrating store: \(error)")
            }
        }
    }
    

    private var managedObjectModel: NSManagedObjectModel!
    private var persistentStoreCoordinator: NSPersistentStoreCoordinator!
    
    private override init() {
        super.init()
        
        guard let modelURL = NSBundle.mainBundle().URLForResource("Model", withExtension:"momd") else {
