         return []
     }
     
-    // MARK: - Private Helpers
+    private func deleteEmptyFolderAtPath(_ path: String) {
+        do {
+            #if swift(>=3.0)
+                guard try FileManager.default.contentsOfDirectory(atPath: path).count == 0 else { return }
+                try FileManager.default.removeItem(atPath: path)
+            #else
+                guard try NSFileManager.defaultManager().contentsOfDirectoryAtPath(path).count == 0 else { return }
+                try NSFileManager.defaultManager().removeItemAtPath(path)
+            #endif
+        } catch let error as NSError {
+            SentryLog.Debug.log(error.localizedDescription)
+        }
+    }
     
-    /// Path of directory to which events will be saved in offline mode
-    private func directory() -> String? {
-        #if swift(>=3.0)
-            guard let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first else { return nil }
-        #else
-            guard let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first else { return nil }
-        #endif
+    private func appendSentryDirToPath(_ path: String?) -> String? {
+        guard let path = path else {
+            return nil
+        }
         
         guard let serverURLString = dsn.url.absoluteString else {
             return nil

     - Throws: Will throw upon failure to create directory
     - Returns: Unique path to which save the given event
     */
    private func writePath(_ event: Event) throws -> String? {
        guard let sentryDir = directory() else { return nil }
        let date = NSDate().timeIntervalSince1970 + 60 + Double(arc4random_uniform(10) + 1)
        
        #if swift(>=3.0)
            try FileManager.default.createDirectory(atPath: sentryDir, withIntermediateDirectories: true, attributes: nil)
            return (sentryDir as NSString).appendingPathComponent("\(date)-\(event.eventID)")
        #else
            try NSFileManager.defaultManager().createDirectoryAtPath(sentryDir, withIntermediateDirectories: true, attributes: nil)
            return (sentryDir as NSString).stringByAppendingPathComponent("\(date)-\(event.eventID)")
        #endif
    }
    

        let directory = "\(directoryNamePrefix)\(serverURLString.hashValue)"
        
        #if swift(>=3.0)
            return (path as NSString).appendingPathComponent(directory)
        #else
            return (path as NSString).stringByAppendingPathComponent(directory)
        #endif
    }
    
    private func documentDirectory() -> String? {
        #if swift(>=3.0)
            guard let path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first else { return nil }
        #else
            guard let path = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first else { return nil }
        #endif
        return path
    }
    
    private func cachesDirectory() -> String? {
        #if swift(>=3.0)
            guard let path = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first else { return nil }
        #else
            guard let path = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true).first else { return nil }
        #endif
        return path
    }
    
    /*
