                     wall :- s/Str
                     distance-maps :- [DistanceMap]
                     path-map :- (s/maybe PathMap)]
-  (let [changed-cells (or (when-not optimize-drawing (g/grid-coords grid))
+  (let [changed-cells (or (when-not optimize-drawing (set (g/grid-coords grid)))
                           (when path-map (:changed-cells (:distances path-map)))
                           (first (map (comp :changed-cells :distances) distance-maps))
                           (:changed-cells grid)
-                          (g/grid-coords grid))]
+                          (set (g/grid-coords grid)))]
     (draw-cell-backgrounds g grid cell-size background distance-maps changed-cells)
     (draw-cell-walls g grid cell-size wall changed-cells)
     (when path-map (draw-path g cell-size path-map changed-cells))

                         cell-size :- g/NonNegativeInt
                         wall :- s/Str
                         changed-cells]
  (println (str "Drawing walls for " (count changed-cells) " cells."))
  (doseq [coord changed-cells]
    (let [[y1 x1] (map #(* % cell-size) coord)
          [y2 x2] (map #(+ % cell-size) [y1 x1])

        ]
    (aset g "imageSmoothingEnabled" false)
    (aset g "fillStyle" background)
    (aset g "lineWidth" strokewidth)
    (when (g/new? grid) (fill-rect g background 0 0 img-width img-height))
    (draw-cells g grid cell-size background wall (remove nil? [dist2 dist1]) path)
    )
