 (defn- qxf-mode->map
   "Builds a map containing a mode specification from a QLC+ fixture
   definition. Currently ignores the Physical documentation."
-  [m]
-  (let [all-channels (mapv qxf-channnel-assigment->vector (zip-xml/xml-> m :Channel))
-        [heads other-channels] (qxf-process-heads (zip-xml/xml-> m :Head) all-channels)]
-    {:name (zip-xml/attr m :Name)
-     :channels other-channels
-     :heads heads}))
+  [channel-specs m]
+  (let [channel-specs (into {} (for [spec channel-specs]  ; Turn specs into a map for efficient searching
+                                 [(:name spec) spec]))
+        all-channels (mapv qxf-channnel-assigment->vector (zip-xml/xml-> m :Channel))
+        channel-map (into {} all-channels)
+        [heads other-channels] (qxf-process-heads (zip-xml/xml-> m :Head) channel-map channel-specs)]
+    (qxf-mark-pan-tilt channel-specs {:name (zip-xml/attr m :Name)
+                                      :channels other-channels
+                                      :heads heads})))
 
 (defn translate-definition
   "Converts a map read by [[convert-qxf]] into an Afterglow fixture

       :model (zip-xml/text (zip-xml/xml1-> root :Model))
       :type (zip-xml/text (zip-xml/xml1-> root :Type))
       :channels channels
       :modes (mapv qxf-mode->map (zip-xml/xml-> root :Mode))
       :has-pan-channel (some #(= "Pan" (:group %)) channels)
       :has-tilt-channel (some #(= "Pan" (:group %)) channels)})))

(defn convert-qxf
  "Read a fixture definition file in the format (.qxf) used by

  "Builds a map containing a channel specification from a QLC+ fixture
  definition."
  [ch]
  (let [color (zip-xml/xml1-> ch :Colour zip-xml/text)]
    (merge {:name (zip-xml/attr ch :Name)
            :group (zip-xml/xml1-> ch :Group zip-xml/text)
            :byte (Integer/valueOf (zip-xml/attr (zip-xml/xml1-> ch :Group) :Byte))
            :capabilities (mapv qxf-capability->map (zip-xml/xml-> ch :Capability))}
           (when color {:color color}))))

(defn qxf-channnel-assigment->vector
  "Builds a vector containing the offset at which a channel exists in
