        :nc channel-index :nz (screen-state :z) :nt 0})))
 
 (defn overlay-loader
-  "Creates overlay tiles for visible monochrome tiles in memory."
+  "Creates overlay tiles needed for drawing."
   [screen-state-atom memory-tile-atom overlay-tiles-atom]
   (doseq [tile (visible-tile-indices @screen-state-atom :overlay)]
     (tile-cache/add-tile overlay-tiles-atom

                         (multi-color-tile memory-tile-atom tile
                                           (:channels @screen-state-atom)))))

(defn monochrome-loader
  "Loads monochrome tiles needed for drawing."
  [screen-state-atom memory-tile-atom]
  (doseq [tile (mapcat #(visible-tile-indices @screen-state-atom %)
                       (keys (:channels @screen-state-atom)))]
    (tile-cache/load-tile memory-tile-atom tile)))

(defn load-visible-only
  "Runs visible-loader whenever screen-state-atom changes."
  [screen-state-atom memory-tile-atom
   overlay-tiles-atom acquired-images]
  (let [load-monochrome (fn [_ _]
                          (monochrome-loader
                            screen-state-atom
                            memory-tile-atom))
        load-overlay (fn [_ _]
                       (overlay-loader
                         screen-state-atom
                         memory-tile-atom

        agent (agent {})]
    (def agent1 agent)
    (reactive/handle-update
      screen-state-atom
      load-overlay
      agent)
    (reactive/handle-update
      acquired-images
      load-overlay
      agent)))
  
;; MAIN WINDOW AND PANEL
