         self.trans = 0
         super.init()
     }
+    init(name:String, link:URL, time:TimeInterval, rank:Int, rect:NSRect, label:Bool, hover:Bool, alpha:Float, trans: Int) {
+        self.name = name
+        self.link = link
+        self.time = time
+        self.rank = rank
+        self.rect = rect
+        self.label = label
+        self.hover = hover
+        self.alpha = alpha
+        self.trans = trans
+        super.init()
+    }
+    
     override var description : String {
         return String(format: "%@: %p '%@'", self.className, self, name)
+    }
+    
+    required convenience init(coder: NSCoder) {
+        let name = coder.decodeObject(forKey: "name") as! String
+        let link = URL.init(string: coder.decodeObject(forKey: "link") as! String)
+        let time = coder.decodeDouble(forKey: "time")
+        let rank = coder.decodeInteger(forKey: "rank")
+        let rect = NSRectFromString(coder.decodeObject(forKey: "rect") as! String)
+        let label = coder.decodeBool(forKey: "label")
+        let hover = coder.decodeBool(forKey: "hover")
+        let alpha = coder.decodeFloat(forKey: "alpha")
+        let trans = coder.decodeInteger(forKey: "trans")
+        self.init(name: name, link: link!, time: time, rank: rank, rect: rect, label: label, hover: hover, alpha: alpha, trans: trans)
+    }
+    
+    func encode(with coder: NSCoder) {
+        coder.encode(name, forKey: "name")
+        coder.encode(link, forKey: "link")
+        coder.encode(time, forKey: "time")
+        coder.encode(rank, forKey: "rank")
+        coder.encode(NSStringFromRect(rect), forKey: "rect")
+        coder.encode(label, forKey: "label")
+        coder.encode(hover, forKey: "hover")
+        coder.encode(alpha, forKey: "alpha")
+        coder.encode(trans, forKey: "trans")
     }
 }
 

    override func writeSafely(to url: URL, ofType typeName: String, for saveOperation: NSSaveOperationType) throws {
        do {
            try self.write(to: url, ofType: typeName)
            Swift.print("writeSafely: \(url.absoluteString)")
        } catch let error {
            NSApp.presentError(error)
        }

    
    // See values in HeliumPanelController.TranslucencyPreference
    let translucencyPreference = Setup<HeliumPanelController.TranslucencyPreference>("rawTranslucencyPreference", value: .never)
}

class HeliumDocumentController : NSDocumentController {
    override func makeDocument(for urlOrNil: URL?, withContentsOf contentsURL: URL, ofType typeName: String) throws -> NSDocument {
        var doc: Document
        do {
            doc = try Document.init(contentsOf: contentsURL, ofType: contentsURL.pathExtension)
            if (urlOrNil != nil) {
                doc.fileURL = urlOrNil
                doc.fileType = urlOrNil?.pathExtension
            }
        } catch let error {
            NSApp.presentError(error)
            doc = try Document.init(contentsOf: contentsURL, ofType: contentsURL.pathExtension)
        }
        return doc
    }
}

class Document : NSDocument {
