     new-worlds))
 
 (om/root
- render-root
- world-state
- {:target (. js/document (getElementById "app"))
+  render-root
+  world-state
+  {:target (. js/document (getElementById "app"))
   :tx-listen (fn [tx-data world-state])})
    (cloxp/with-con
      (fn [con]
        (go
         (<! (start-cljs-compile-service con))
         (loop [world init-world
                transitions init-transitions
                current-signal {:type nil ; the type of signal, i.e. mouse-move, redefine, step...

                                  (morph-under-me world-state (props :id) id))))]
     (or sub-container-id container-id))))

; MORPH FUNCTIONS

(defn set-prop [world id prop-name prop-value]
  "Set the property prop-name of morph with id in world to prop-value"
  (putback world [($morph id) properties prop-name] prop-value))

(defn add-morphs-to [world id morphs]
  "Add collection of morphs to the morph with id in world"
  (-> world (redefine ($morph id) (fn [self props submorphs]
                           (self props 
                                 morphs
                                 submorphs)))))

(defn add-morph [world id morph]
  "Add single morph to the morph with id"
  (-> world (redefine ($morph id) (fn [self props submorphs]
                           (self props
                                 submorphs
                                 morph)))))

(defn add-morph-before [world id before-id morph]
  "Just as add-morph, but adds morph in front of the morph with before-id"
  (-> world (redefine ($morph id) (fn [self props submorphs]
                                    (let [[before after] (split-with (fn [[_ {:id id} & _]]
                                                                     (not= id before-id)) 
                                                                     submorphs)]
                                      (self props
                                            before
                                            morph
                                            after))))))

(defn without [world id]
  "Return a world without the morph with the given id."
  (redefine world ($morph id) (fn [self props submorphs])))

(defn get-description 
  ([world-state id]
   "In this case we just return a plain old new description. This is kind of expensive though."
   (fetch world-state [($morph id) description]))
  
  ([world-state id change]
   "If we supply a change {:id :prop :value} with our request, we return a description
    based on the previously cached one and just replace the changed information
    with regexp magic."
   (let [morph (fetch world-state ($morph id))
         [self props submorphs] morph
         ; THIS SHOULD BE HANDLED BY THE LENS. META DATA MAY NOT BE TOUCHED BY THE USER
         cached-code (:cached-code (meta morph))
         morph-re (str "\\{[^\\(]*\\:id\\s\\\"" (:id change) "\\\"[^\\(]*\\}(\n?)")
         new-props (:new-props change)]
     (if (or (:restructured? change) (nil? @cached-code))
      (do
         ; we have not cached or the morph got moved, so the change is not helpful at all
         (reset! cached-code (-> (self props submorphs)
                                 pprint
                                 with-out-str)))
      (do
         ; we have cached the value previously, so we can now just apply a regexp substitute
         ; or just return the cached value
         (if (nil? new-props)
          @cached-code
          (swap! cached-code #(replace-first % (re-pattern morph-re)
                                              (-> new-props 
                                                pprint
                                                with-out-str)))))))))
