   compile: ->
     result =
       targets: []
-
-    compiler = (prop)-> (target)-> target[prop]
-
-    for rule in @rootMist.rules
+      commands: {}
+
+    for rule in @rootMist.rules
+      result.commands[rule.command.hash] =
+        command: rule.command.command
+
       if rule.src.foreach
         for input, target of rule.targets
           result.targets.push
+            command: rule.command.hash
             inputs: [input]
             dependenies: target.dependencies.compile()
             orderDependencies: target.orderDependencies.compile()

            auxOutputs: target.auxOutputs.compile()
      else
        result.targets.push
          inputs:
            (k for k of rule.targets).compile()
          dependencies:

  constructor: (@rootDir, @rootMist)->
    @groupRefs = {}

    @compileCommands()
    @setupTargets()
    @generateTemplates()
    @generateTargets()

  ###
  # Compiles all commands
  ###
  compileCommands: ->
    for rule in @rootMist.rules
      rule.command =
        hash: Hasher.hash rule.src.command
        command: MistResolver.delimitCommand rule.src.command

  ###
  # Creates a targets object for each rule
