         self.settings.opacityPercentage.value = (plist[k.alpha] as AnyObject).intValue ?? 60
         self.settings.translucencyPreference.value = HeliumPanelController.TranslucencyPreference(rawValue: (plist[k.trans] as AnyObject).intValue ?? 0)!
     }
-
-    func updateURL(to url: URL, ofType typeName: String) {
-        if typeName == "h3w" {
-            if let dict = NSDictionary(contentsOf: url) {
-                var items: [PlayItem] = [PlayItem]()
-                for (key,list) in dict {
-                    for item in list as! [Dictionary<String,Any>] {
-                        let playitem = PlayItem.init(with: item )
-                        items.append(playitem)
-                    }
-                    var playname = key as! String
-                    var nbr = 0
-                    while true {
-                        if playlists[playname] == nil
-                        {
-                            break
-                        }
-                        else
-                        {
-                            nbr += 1
-                            playname = String(format: "%@%@", key as! String,
-                                              (nbr == 0 ? "" : String(format: "-%ld", nbr)))
-                        }
-                    }
-                    playlists[playname] = items
-                }
-            }
-        }
-        else
-        {
-            fileType = url.pathExtension
-            fileURL = url
-        }
+    
+    func update(to url: URL, ofType typeName: String) {
+        if let dict = NSDictionary(contentsOf: url) {
+            if let item = dict.value(forKey: "settings") {
+                self.restoreSettings(with: item as! Dictionary<String,Any> )
+            }
+        }
+        fileType = typeName
+        fileURL = url
         self.save(self)
     }
     
     override init() {
-        // Add your subclass-specific initialization here.
-
-        playlists = Dictionary<String, Any>()
         settings = Settings()
-        
         super.init()
     }
     

    }
    
    override func write(to url: URL, ofType typeName: String) throws {
        switch typeName {
        case "h3w":
            let dict = NSDictionary.init()
            for (name,playitem) in playlists {
                let item = (playitem as! PlayItem).dictionary()
                dict.setValue(item, forKey: name)
            }
            dict.write(to: url, atomically: true)
            break
            
        default:
            //  "DocumentType" writter to user defaults play items dictionary
            var lists = UserDefaults.standard.dictionary(forKey: UserSettings.Playitems.default) ?? NSDictionary.init() as! [String : Any]
            for (name,list) in playlists {
                var items = [Dictionary<String,Any>]()
                for item in list as! [PlayItem] {
                    items.append(item.dictionary())
                }
                lists[name] = items
            }
            
            //  Cache ourselves too
            let item = self.dictionary()
            lists[self.displayName] = item
            
            UserDefaults.standard.set(lists, forKey: UserSettings.Playlists.default)
            UserDefaults.standard.synchronize()
        }
        self.updateChangeCount(.changeCleared)
    }
    override func writeSafely(to url: URL, ofType typeName: String, for saveOperation: NSSaveOperationType) throws {
        do {


class Document : NSDocument {

    var settings: Settings
    
    func dictionary() -> Dictionary<String,Any> {
