   (get (get m (string/lower-case nml) {}) (string/lower-case key) ""))
 
 (defn nml-map [s src]
-  (let [f0   (fn [& nvsubseqs   ] (into {} nvsubseqs))
-        f1   (fn [dataref values] { (nml-str dataref) (nml-str values) })
-        f2   (fn [& stmts       ] (into {} stmts))
-        f3   (fn [name & nvseq  ] { (nml-str name) (first nvseq) })
-        tree (nml-tree s src)]
-    (insta/transform {:nvseq f0 :nvsubseq f1 :s f2 :stmt f3 } tree)))
+  (let [tree (nml-parse s :s src)
+        transformers
+        {
+         :c identity
+         :dataref #(apply string/lower-case %)
+         :name #(apply string/lower-case %)
+         :nv_sequence (fn [& nv_subsequences] (into {} nv_subsequences))
+         :nv_subsequence (fn [name values] {name values})
+         :nv_subsequence_begin #(apply string/lower-case %)
+         :partref #(apply string/lower-case %)
+         :s (fn [& nv_sequences] (into {} nv_sequences))
+         :stmt (fn [name nv_sequence _] (into {} {name nv_sequence}))
+         :string (fn [& letters] (apply str letters))
+         :value identity
+         :values (fn [& values] (into [] values))
+         }]
+    (println (str "#PM# 0 " tree))
+    (let [newtree (insta/transform transformers tree)]
+      (println (str "#PM# 1 " newtree))
+      newtree)))
 
 (defn nml-set [m nml key val]
   (let [src (str "user-supplied value")


(defn- nml-parse [s start src]
  (let [result (parse s :start start)]
    (let [parses (insta/parses parse s :start start :unhide :all :trace true)]
      (binding [*out* *err*]
        (doseq [parse parses] (println (str "----\n" parse)))
        (println (str "### " (count parses)))))
    (println (str "@@@ " result))
    (if (insta/failure? result)
      (let [{t :text l :line c :column} result]
        (fail (str "Error parsing " src " at line " l " column " c ":")

                     :wsopt                 ""
                     val))))

(defn- nml-uniq [values]
  (loop [head (first values) tail (rest values) tree []]
    (if (nil? head)
