   (.getMinutes @selected-time))
 
 (defn set-hours! [new-hours]
-  (swap! selected-time #(doto % .setHours new-hours)))
+  (swap! selected-time #(doto % (.setHours new-hours))))
 
 (defn set-minutes! [new-mins]
-  (swap! selected-time #(doto % .setMinutes new-mins)))
+  (swap! selected-time #(doto % (.setMinutes new-mins))))
 
 (defn sync-time-with-snapshot! []
-  (swap! selected-time #(js/Date. (:time @snapshot-index))))
+  (reset! selected-time (js/Date. (:time (@snapshot-list @snapshot-index)))))
 
 ; TODO: This could be improved. Probably need to rethink my data model
 (defn show-closest-snapshot! []
   (let [timestamp (.getTime @selected-time)
-        earlier-index (keep-indexed #(if (>= timestamp (:time %2)) %1) @snapshot-list)
-        later-index (dec earlier-index)
+        earlier-index (first (keep-indexed #(if (>= timestamp (:time %2)) %1) @snapshot-list))
+        later-index (max (dec earlier-index) 0)
         later (:time (@snapshot-list later-index))
         earlier (:time (@snapshot-list earlier-index))
         display-index (if (< (- later timestamp) (- timestamp earlier))
                         later-index
                         earlier-index)]
-    (swap! snapshot-index #(display-index))))
+    (reset! snapshot-index display-index)))
 
 (defn set-url! [timestamp]
   (let [base-url (.split js/document.URL "?")

      (sync-time-with-snapshot!))))

(defn click-earlier []
  (if (>= @snapshot-index (count @snapshot-list))
    (do
      (swap! snapshot-index inc)
      (sync-time-with-snapshot!))))


(defn add-events []
  (aset js/window "onpopstate" on-popstate)
  (on ($ "#datepicker") "changeDate" on-datetime-change)
  (on ($ js/document) "keydown" on-keydown)

  (-> ($ "body")
