 import Foundation
 import Zip
 
+/// File manager that manages utree files
 public class UsbongFileManager {
-    // Make sure it can't be initialized
+    /// Only one instance of `UsbongFileManager` is allowed
     private init() {
         // Set custom file extension for Zip
         Zip.addCustomFileExtension("utree")
     }
     
+    /// Property for storing the default `UsbongFileManager`
     private static var _defaultManager = UsbongFileManager()
+    
+    /// Get the default `UsbongFileManager`
     public static func defaultManager() -> UsbongFileManager {
         return UsbongFileManager._defaultManager
     }
     
+    /// The root URL where `UsbongFileManager` will search for utree files
     public var rootURL: NSURL = {
         // Default root URL is App's Documents folder
         let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
         return urls[urls.count-1]
     }()
+    
+    /// The cache URL where utrees will be unzipped
     public var cacheDirectoryURL: NSURL = {
         // Default cache directory is ./Library/Caches/trees/
         let urls = NSFileManager.defaultManager().URLsForDirectory(.CachesDirectory, inDomains: .UserDomainMask)
         return urls[urls.count-1].URLByAppendingPathComponent("trees", isDirectory: true)
     }()
     
+    /// Default filename for utree files
     public var defaultFileName = "Untitled"
     
+    /// Get the contents of `rootURL`
     public func contentsOfDirectoryAtRootURL() -> [NSURL]? {
         return try? NSFileManager.defaultManager().contentsOfDirectoryAtURL(rootURL, includingPropertiesForKeys: nil, options: NSDirectoryEnumerationOptions.SkipsHiddenFiles)
     }
     
+    /// Clears the cache directory
     public func clearCacheDirectory() -> Bool {
         do {
             try NSFileManager.defaultManager().removeItemAtURL(cacheDirectoryURL)

        }
    }
    
    public func unpackTreeToCacheDirectoryWithTreeURL(treeURL: NSURL) -> NSURL? {
        // Generate unique string to ensure unpack to new clean directory
        let uniqueId = NSUUID().UUIDString

        }
    }
    
    /// Get the utree files inside `rootURL`
    public func treesAtRootURL() -> [NSURL] {
        if let contents = contentsOfDirectoryAtRootURL() {
            // filter contents to URLs with path extension 'utree'
            return contents.filter { $0.pathExtension == "utree" }
        }
        
        // Return empty array if contents is nil
        return []
    }
    
    /**
     Get the first found folder with .utree extension. This is typically used for the unpacked .utree.
     
     - parameter url: URL of unpacked .utree
     
     - returns: URL of folder with .utree extension
    */
    public func firstTreeInURL(url: NSURL) -> NSURL? {
        // Get directory of .utree folder in unpack directory
        let contents = try? NSFileManager.defaultManager().contentsOfDirectoryAtURL(url, includingPropertiesForKeys: nil, options: NSDirectoryEnumerationOptions.SkipsHiddenFiles)
