     # Get chip data
     [chipType, chipName] = chips.getChipTypeAndName(chip)
 
-    chipsToCopy = @listChipsToCopy(sourceGameCode, chipType, chipName)
+    chipsToCopy = @listChipsToCopy(sourceGameCode, chip)
     copiedChipCount = 0
     for chipToCopy in chipsToCopy
       if @copySingleChip(sourceGameCode, currentGame.version, chipToCopy...) then copiedChipCount++

    return nextName

  # Return list of dependencies like [[chipAType, chipAName], [chipBType, chipBName], ... ]
  listChipsToCopy: (sourceGameCode, chipType, chipName) ->
    listChipTree = (chip, list = []) =>
      list.push(chips.getChipTypeAndName(chip))
      if chip.children
        for child in chip.children
          listChipTree(child, list)
      return list

    recursiveSearch = (chipType, chipName, dependencies) =>
      # Add self to list
      if chipType not in ["emitter", "splitter"]
        dependencies.push([chipType, chipName])

      if chipType is "circuit"
        circuitDependencies = listChipTree(sourceGameCode.circuits[chipName].board)
        for circuitDependency in circuitDependencies
          recursiveSearch(circuitDependency, dependencies)

      # Add references for transformers referenced in the code
      transformerReferences = []
      switch chipType
        when "processor"
          @getTransformerReferences(sourceGameCode.processors[chipName].update, transformerReferences)
        when "switch"
          @getTransformerReferences(sourceGameCode.switches[chipName].listActiveChildren, transformerReferences)
          @getTransformerReferences(sourceGameCode.switches[chipName].handleSignals, transformerReferences)
        when "transformer"
          @getTransformerReferences(sourceGameCode.transformers[chipName].body, transformerReferences)

      # Add references for transformers referenced in pins
      switch chipType
        when "emitter"
          for pinName, pinExpression of chip.emitter
            @getTransformerReferences(pinExpression, transformerReferences)
        when "processor", "switch"
          for pinName, pinExpression of chip.pins.in
            @getTransformerReferences(pinExpression, transformerReferences)
          for pinName, pinExpression of chip.pins.out
            @getTransformerReferences(pinExpression, transformerReferences)

      for tranformerName in transformerReferences
        recursiveSearch({ transformer: tranformerName }, dependencies)

      return dependencies

    return recursiveSearch(chip, [])

  getTransformerReferences: (code, references = []) ->
    r = /transformers.(\w+)|transfromers\[(\w*)\]/g
    loop
      match = r.exec(code)
      if not match then break
      references.push(match[1])
    return references 

