     @IBOutlet weak var saveButton: NSButton!
     @IBAction func savePlaylists(_ sender: AnyObject) {
         let playArray = playlistArrayController.arrangedObjects as! [NSDictionaryControllerKeyValuePair]
-        var temp = [Dictionary<String,AnyObject>]()
+        var temp = Dictionary<String,Any>()
         for playlist in playArray {
-            var list = Array<AnyObject>()
+            var list = Array<Any>()
             for playitem in playlist.value as! [PlayItem] {
-                let item : [String:AnyObject] = [k.name:playitem.name as AnyObject, k.link:playitem.link.absoluteString as AnyObject, k.time:playitem.time as AnyObject, k.rank:playitem.rank as AnyObject]
-                list.append(item as AnyObject)
-            }
-            temp.append([k.name:playlist.key as AnyObject, k.list:list as AnyObject])
+                let dict = playitem.dictionary()
+                list.append(dict)
+            }
+            temp[playlist.key!] = list
         }
         defaults.set(temp, forKey: UserSettings.Playlists.keyPath)
         defaults.synchronize()

            }
            col.isHidden = isHidden
        }

    }

    var historyCache: NSDictionaryControllerKeyValuePair? = nil
    override func viewWillAppear() {
        // add existing history entry if any AVQueuePlayer
        if historyCache == nil
        {
            historyCache = playlistArrayController.newObject() as NSDictionaryControllerKeyValuePair
            historyCache!.key = UserSettings.HistoryName.value
            historyCache!.value = [PlayItem]()
        }
        else
        if appDelegate.histories.count > 0 {
            playlists[UserSettings.HistoryName.value] = nil
            

        playlistTableView.doubleAction = #selector(playPlaylist(_:))
        playitemTableView.doubleAction = #selector(playPlaylist(_:))
        
        //  Load playlists shared by all document; our delegate maintains history
        self.restorePlaylists(restoreButton)

        NotificationCenter.default.addObserver(
            self,
