   "Adds the reference name pair to namedItems, overwriting any previous allocation.
   Returns the added name"
   ([keyRef valName]
+   (init-named-items)
    (swap! namedItems assoc keyRef valName)
    valName)
   ([[keyRef valName]]


;; Until reset, this will save all references. The same number crisis will
;; continue to return the same names for ##REF-TAGS##
(def namedItems
  "A map atom with references as keys and named items as values"
  (atom {}))

(defn reset-named-items!
  "Resets the namedItems atom"

(defn get-name
  "Returns the referenced name from namedItems, or nil if not existing"
  [keyName]
  (init-named-items)
  (get @namedItems keyName))

(defn named-exists?
  "Returns true if the named item already exists in namedItems, else false"
  [refName]
  (init-named-items)
  (if (some #{refName} (vals @namedItems))
    true
    false))
