                      (let [edges (klay/get-edges r)]
                        (prn "klay: success!")
                        (cmn/d r)
-                       (cmn/d edges)))
-                   (fn [e]
-                    (prn "klay: error")
-                    cmn/d))
-      (let [positions (cmn/index-by :label (dagre/get-nodes g))]
-        {:nodes (for [bb bbs]
-                  (let [pos (get positions (:addr bb))]
-                    (merge bb {:x (:x pos)
-                               :y (:y pos)})))
-         :edges (dagre/get-edges g)}))))
+                       (cmn/d edges)
+                       (s {:nodes (layout-bbs (cmn/index-by :id (klay/get-nodes r)) bbs)
+                           :edges (klay/get-edges r)})))
+                   (fn [err]
+                     (prn "klay: error")
+                     (cmn/d err)
+                     (e err)))
+      (s {:nodes (layout-bbs (cmn/index-by :label (dagre/get-nodes g)) bbs)
+          ;; TODO: recover edge src, dst
+          :edges (dagre/get-edges g)}))))
 
 
 (defn positioned

    (prn (str (:type edge) " " (hex-format (:src edge)) " -> " (hex-format (:dst edge))))))


(defn layout-cfg
  [basic-blocks]
  (when (< 0 (count (remove nil? basic-blocks)))
    (let [edges (compute-edges basic-blocks)
          bbs (map #(assoc % :width (compute-bb-width %)) basic-blocks)

           function (get-in props [:functions fva])
           basic-blocks (:basic-blocks function)
           basic-blocks (map #(get-in props [:basic-blocks (:addr %)]) basic-blocks)
           g (layout-cfg basic-blocks (fn [layout] (cmn/d layout)) (fn [err] (cmn/d err)))]
       (canvas
        {}
        [(for [bb (:nodes g)]
