   }
 
   func add(item: NSMenuItem) {
-    let index = max(0, menu.items.count - defaultCount)
-    menu.insertItem(item, at: index)
+    menu.insertItem(item, at: max(0, menu.items.count - defaultCount))
   }
 
-  var attributedTitle: NSMutableAttributedString {
+  var attributedTitle: Mutable {
     set { item.attributedTitle = newValue }
     get {
       if let title = item.attributedTitle {
         return title.mutable()
       }
 
-      var title = NSMutableAttributedString(string: "")
-      if let aTitle = item.title {
-        title = NSMutableAttributedString(string: aTitle)
+      if let title = item.title {
+        return Mutable(string: title)
       }
-      item.attributedTitle = title
-      return title
+
+      return Mutable(string: "")
     }
   }
 

import AppKit
import EmitterKit
import Cocoa
import SwiftyUserDefaults

/**
  Represents an item in the menu bar

    instead of using isVisible = false or hide()
*/
class Tray: NSObject, NSMenuDelegate, ItemBaseDelegate {
  private static let center = NSStatusBar.system()
  private static let length = NSVariableStatusItemLength

  private var updatedAgoItem: UpdatedAgoItem?
  private var listeners = [Listener]()
  private let openEvent = Event<Void>()
  private let closeEvent = Event<Void>()
  private let openInTerminalClickEvent = Event<Void>()
  private var isOpen = false
  private let menu = NSMenu()
  private var defaultCount = 0
  private let item = Tray.center.statusItem(withLength: Tray.length)
  internal weak var delegate: TrayDelegate?

  /**
