             queue = []
             return
 
+          @stacksById   = {}
+          for stack in stacks
+            @stacksById[stack._id] = stack
+
           @machinesById = {}
 
           machines = []

    @stacks       = []
    @machines     = []
    @machinesById = {}
    @plans        = null
    @_trials      = {}


  findMachineFromMachineId: (machineId)->
    return @machinesById[machineId]

  findStackFromStackId: (stackId)->
    return @stacksById[stackId]

  findStackFromMachineId: (machineId)->
    for stack in @stacks
      return stack  if machineId in stack.machines

  findMachineFromQueryString: (queryString)->

