     (+ arcs-x-dist tangent-x-dist)))
 
 
-(defn arc-center-up
-  "Given node info map (must have :node-y) and a min-arc-radius, returns the
-  center for the upward arcs on that node"
-  [{:keys [node-y]} min-arc-radius]
-  {:pre [(vector? node-y) (number? min-arc-radius)]}
-  (- (node-y 0) min-arc-radius))
-
-
-(defn arc-center-down
-  "Given node info map (must have :node-y) and a min-arc-radius, returns the
-  center for the downward arcs on that node"
-  [{:keys [node-y]} min-arc-radius]
-  {:pre [(vector? node-y) (number? min-arc-radius)]}
-  (+ (node-y 1) min-arc-radius))
-
-
-(defn arc-radius-up
+(defn arc-radius
   "Given node info map (must have :order) a min-arc-radius and the number of
   pixels characters should be separated by, and returns the radius of the arc
   for that node for that character"
   [{:keys [order]} min-arc-radius char-sep]
   {:pre [(integer? order) (every? number? [min-arc-radius char-sep])]}
-  (+ min-arc-radius
-     (* order char-sep)))
-
-
-(defn arc-radius-down
-  "Given node info map (must have :order and :node, which in turn must
-  have :weight) a min-arc-radius and the number of pixels characters should be
-  separated by, and returns the radius of the arc for that node for that
-  character"
-  [{:keys [order] {weight :weight} :node} min-arc-radius char-sep]
-  {:pre [(every? integer? [order weight])
-         (every? number? [min-arc-radius char-sep])]}
-  (+ min-arc-radius
-     (* (- (dec weight) order)
-        char-sep)))
+  (+ min-arc-radius (* order char-sep)))
 
 
 (defn arc-y-info
   "Returns the y values of the arc centers, as well as the radii for each arc
-  for a pair of character nodes on adjacent layers"
+  for a character segment with endpoints on adjacent layers"
   [src dest dir min-arc-radius char-sep]
   {:pre [(contains? #{:up :down} dir)]}
-  (if (= dir :up)
-    {:src-arc-y (arc-center-up src min-arc-radius)
-     :src-arc-radius (arc-radius-up src min-arc-radius char-sep)
-     :dest-arc-y (arc-center-down dest min-arc-radius)
-     :dest-arc-radius (arc-radius-down dest min-arc-radius char-sep)}
-    {:src-arc-y (arc-center-down src min-arc-radius)
-     :src-arc-radius (arc-radius-down src min-arc-radius char-sep)
-     :dest-arc-y (arc-center-up dest min-arc-radius)
-     :dest-arc-radius (arc-radius-up dest min-arc-radius char-sep)}))
+  (let [src-arc-r (arc-radius src min-arc-radius char-sep)
+        dest-arc-r (arc-radius dest min-arc-radius char-sep)
+        [src-op dest-op] ({:up [- +] :down [+ -]} dir)]
+    {:src-arc-radius src-arc-r
+     :dest-arc-radius dest-arc-r
+     :src-arc-y (src-op (:y src) src-arc-r)
+     :dest-arc-y (dest-op (:y dest) dest-arc-r)}))
 
 
 (defn add-y-info
-  "Adds :arc-y and :arc-radius information to character path pairs, plus
+  "Adds :arc-y and :arc-radius information to character segments, plus
   :total-arc-radius, for convenience"
-  [pair-maps min-arc-radius char-sep]
-  (map (fn [{:keys [dir], [src dest] :pair, :as info}]
+  [char-segs min-arc-radius char-sep]
+  (map (fn [{:keys [dir src dest], :as seg}]
          (if (= dir :level)
-           info
+           seg
            (let [{:keys [src-arc-y dest-arc-y
                          src-arc-radius dest-arc-radius]}
                  (arc-y-info src dest dir min-arc-radius char-sep)]
-             (-> info
+             (-> seg
                  (assoc :total-arc-radius (+ src-arc-radius dest-arc-radius))
-                 (assoc-in [:pair 0 :arc-y] src-arc-y)
-                 (assoc-in [:pair 0 :arc-radius] src-arc-radius)
-                 (assoc-in [:pair 1 :arc-y] dest-arc-y)
-                 (assoc-in [:pair 1 :arc-radius] dest-arc-radius)))))
-       pair-maps))
+                 (assoc-in [:src :arc-y] src-arc-y)
+                 (assoc-in [:src :arc-radius] src-arc-radius)
+                 (assoc-in [:dest :arc-y] dest-arc-y)
+                 (assoc-in [:dest :arc-radius] dest-arc-radius)))))
+       char-segs))
 
 
 (defn add-x-info
-  "Adds :xs to character path pairs, and if the pairs are not :level, also
-  adds :arc-x for each pair"
-  [pair-maps layer-xs]
-  (map (fn [{:keys [dir], [src dest] :pair, :as info}]
+  "Adds :xs to character segments, and if the segment is not :level, also
+  adds :arc-x for each segment"
+  [char-segs layer-xs]
+  (map (fn [{:keys [dir src dest], :as seg}]
          (let [src-xs (-> src :node :layer-id layer-xs)
                dest-xs (-> dest :node :layer-id layer-xs)
-               info' (-> info
-                         (assoc-in [:pair 0 :xs] src-xs)
-                         (assoc-in [:pair 1 :xs] dest-xs))]
+               seg' (-> seg
+                        (assoc-in [:src :xs] src-xs)
+                        (assoc-in [:dest :xs] dest-xs))]
            (if (= dir :level)
-             info'
-             (-> info'
-                 (assoc-in [:pair 0 :arc-x] (src-xs 1))
-                 (assoc-in [:pair 1 :arc-x] (dest-xs 0))))))
-       pair-maps))
+             seg'
+             (-> seg'
+                 (assoc-in [:src :arc-x] (src-xs 1))
+                 (assoc-in [:dest :arc-x] (dest-xs 0))))))
+       char-segs))
 
 
 (defn pair-up
   "Given a list of character positions, pairs each with the one following for a
   representation of transistions between layers. Also adds information about
-  the direction this transition goes."
+  the direction this segment goes."
   [infos]
   (->> (map vector infos (drop 1 infos))
-       (reduce (fn [pairs [src dest]]
+       (reduce (fn [segments [src dest]]
                  (let [src-y (:y src)
                        dest-y (:y dest)]
-                   (conj pairs
+                   (conj segments
                          {:dir (if (= src-y dest-y)
                                  :level
                                  (if (> src-y dest-y)
                                    :up
                                    :down))
-                          :pair [src dest]})))
+                          :src src
+                          :dest dest
+                          :character (:character src)})))
                [])))
 
 
 (defn relative-layer-xs
   "Generates a map of layers to the pixel distance to the preceding layer"
   [path-info layers max-slope layer-sep]
-  (->> (map second path-info)
+  (->> (vals path-info)
        (mapcat #(remove (fn [{:keys [dir]}] (= dir :level)) %))
-       (reduce (fn [min-seps {:keys [dir total-arc-radius],
-                              [src dest] :pair}]
+       (reduce (fn [min-seps {:keys [dir total-arc-radius src dest]}]
                  (let [layer (get layers (-> dest
                                              :node
                                              :layer-id))

    (match [last-type dir]
           [:h :level] (extend-h plots' dest-end-x)
           [_ :level] (conj plots' (h-to dest-end-x))
           :else (plot-duration (into plots' (arcs-and-tangent pair-map))
                                dest-start-x dest-end-x))))



  (let [class-graphs (FlatGraph->ClassGraphs flat-graph)
        narrowest (apply min-key #(width % node-sep char-sep) class-graphs)
        narrow-min-y (min-y narrowest node-sep char-sep)
        narrow-max-y (max-y narrowest node-sep char-sep)
        y-map (->> class-graphs
                   (map #(let [delta (if (:aligned-down (meta %))
                                       (- narrow-max-y (max-y % node-sep
                                                              char-sep))
                                       (- narrow-min-y (min-y % node-sep
                                                              char-sep)))]
                           (ys % node-sep char-sep delta)))
                   (apply merge-with #(if (vector? %1) (conj %1 %2) [%1 %2]))
                   (map (fn [[node ys]]
                          (let [sort-ys (sort ys)]
                            [node (/ (+ (nth sort-ys 1) (nth sort-ys 2)) 2)])))
                   (into {}))]
    (map (fn [node]
           (let [top-y (get y-map node)
                 bot-y (+ top-y
                            (* char-sep
                               (dec (:weight node))))]
             [node [top-y bot-y]]))
         (nodes flat-graph))))


(defn arc-distance
