 
 (defn xpand-fn
   [head form src-map fn-meta path path-parent]
-  (let [path-parent' (conj path-parent path)]
-    {:template {path (mk-tree-template src-map
-                                       (get-form-meta-somehow form)
-                                       fn-meta
-                                       path-parent')}
-     :form (xpand-fn-form head
-                          (xpand-all form
-                                     src-map
-                                     fn-meta
-                                     path
-                                     path-parent'))}))
+  (let [xmap (xpand-all form
+                        src-map
+                        fn-meta
+                        path
+                        path-parent)]
+    (layer-xpansion-maps xmap
+                         {:path-parents {path path-parent}
+                          :templates {path (mk-tree-template src-map
+                                                             (get-form-meta-somehow form)
+                                                             fn-meta
+                                                             path)}
+                          :form (xpand-fn-form head
+                                               (:form xmap)
+                                               (path->sym path))})))
 
 #_(defn xpand-form
   [form src-map fn-meta & [path path-parent]]

                  (map-indexed (partial xpand-body
                                        parent-fn-meta))
                  prep-traced-bods)]
    `(let [~'$$p ~(:paths bods)
           ~@(:templates bods)]
       (fn ~@(:bods bods)))))

(defn get-fn
  [[d s f & r]]

  :NOT-IMPLEMENTED)

(defn mk-tree-template
  [src-map frm-meta fn-meta path & {:keys [macro?]}]
  (let [sub-src-map (->> path
                         rest
                         (remove #{:macro})
                         src-map)
        form (if macro?
               (:orig sub-src-map)
               (:x sub-src-map))]
    {:inner-body-idx (first path)
     :inner-path path
     :name (if (seq? form)
             (first form)
             form)
     :form form
     :macro? macro?
     :parent-name (symbol (format "%s/%s"
                                  (-> fn-meta :ns str)
                                  (:name fn-meta)))
     :ns (-> fn-meta :ns str symbol)
     :xpanded-frm (:x sub-src-map)
     :src-pos (select-keys frm-meta [:line :column :end-line :end-column :file])}))

