         self.add(reference: ref)
     }
     
-    mutating func changeReference(reference: Reference) {
+    mutating func changeReference(reference: Reference?) {
         self.add(reference: reference)
     }
     

class HistoryHelper {

    @objc static func saveCurrentAtTerminate(note: NSNotification) {
        SettingsDB.shared.storeHistory(history: HistoryModel.shared.currentHistory())
        SettingsDB.shared.cleanUpHistory()
    }
}

        SettingsDB.shared.clearHistory()
    }
    
    private mutating func add(reference: Reference?) {
        if CFAbsoluteTimeGetCurrent() - self._current.datetime > HistoryModel.SAVE_ON_DELAY
            && self._current != self._history.last {
            self._history.append(self._current)
            SettingsDB.shared.storeHistory(history: self._current)
        }
        if reference != nil {
            self._current = History(reference: reference!)
        }
    }
    
    func current() -> Reference {
