         }
     }
     
+    private func deleteIfExists(fileURL url: NSURL) {
+        
+        let fileManager = NSFileManager.defaultManager()
+        
+        do {
+            try fileManager.removeItemAtURL(url)
+            
+        } catch let error as NSError {
+            logError { "Could not delete file \(url), error was: \(error.localizedDescription)" }
+        }
+    }
+    
     private dynamic func handleContextDidSaveNotification(notification: NSNotification)  {
         
         if let context = notification.object as? NSManagedObjectContext {

                    logInfo(tag) { "Attempting to remove file \(storeURL) and -shm and -wal files" }
                    if let path = storeURL.path {

                        let fileManager = NSFileManager.defaultManager()

                        try fileManager.removeItemAtURL(storeURL)
                        try fileManager.removeItemAtURL(NSURL(fileURLWithPath: "\(path)-shm"))
                        try fileManager.removeItemAtURL(NSURL(fileURLWithPath: "\(path)-wal"))
                    }

                    logInfo(tag) { "Attaching new persistent store \"\(storeURL.lastPathComponent ?? "Unknown")\" for type: \(persistentStoreType)."}


                logInfo(tag) { "Checking to see if persistent store is compatible with the model." }

                if model.isConfiguration(configuration, compatibleWithStoreMetadata: metadata) {

                    logInfo(tag) { "Model is incompatible. Attempting to remove the persistent store." }
                    try persistentStoreCoordinator.removePersistentStore(persistentStore)
