   (println "saved data and settings: " (:display-columns (get-current-data-and-settings))))
 
 (defn load-data-and-settings [name]
+  (save-last-collection name)
   (let [f (get @collections name)]
     (apply-data-and-settings (read-json (slurp f))))
-    (.setSelectedItem (@browser :collection-menu) name))
+  (update-collection-menu name))
 
 (defn user-creates-collection []
   (let [prompt-msg "Please enter a name for the new collection."]

                         prompt-msg))
           :else collection-name)))))

(defn update-collection-menu []
  (let [menu (@browser :collection-menu)
        names (sort (keys @collections))
        listeners (.getItemListeners menu)]
    (dorun (map #(.removeItemListener menu %) listeners))
    (.removeAllItems menu)
    (dorun (map #(.addItem menu %) names))
    (.addItem menu "New...")
    (.addItem menu "Load...")
    (dorun (map #(.addItemListener menu %) listeners))))

(defn new-data-and-settings []
  (let [collection-name (user-creates-collection)]
    (swap! collections assoc collection-name

    (getValueAt [row column] (nth (nth @current-data row) column))
    (getColumnName [column] (nth tags column))))

(defn get-row-path [row]
  (nth row (.indexOf tags "Path")))

(defn refresh-row [rows new-row]
  (let [changed (atom false)
        new-path (get-row-path new-row)
        data
          (vec
            (for [row rows]
              (if (= (get-row-path row) new-path)
                (do (reset! changed true) new-row)
                row)))]
    (if @changed
      data
      (conj data new-row))))

(defn add-browser-table-row [new-row]
  (swap! current-data refresh-row (vec new-row))
  (.fireTableDataChanged (.getModel (@browser :table))))

(defn remove-browser-table-row [n]
  (swap! current-data remove-nth n)
