     return
 
   getBracketContext: (type, port, scope, idx) ->
-    portname = port
-    if @inPorts[port].isAddressable()
-      portname = "#{port}[#{idx}]"
+    {name, index} = ports.normalizePortName port
+    portsList = if type is 'in' then @inPorts else @outPorts
+    if portsList[name].isAddressable() and idx
+      port = "#{port}[#{idx}]"
     # Ensure we have a bracket context for the current scope
-    @bracketContext[type][portname] = {} unless @bracketContext[type][portname]
-    @bracketContext[type][portname][scope] = [] unless @bracketContext[type][portname][scope]
-    return @bracketContext[type][portname][scope]
+    @bracketContext[type][port] = {} unless @bracketContext[type][port]
+    @bracketContext[type][port][scope] = [] unless @bracketContext[type][port][scope]
+    return @bracketContext[type][port][scope]
 
   addToResult: (result, port, ip, before = false) ->
     {name, index} = ports.normalizePortName port

        for port in context.ports
          ipClone = context.closeIp.clone()
          @addToResult result, port, ipClone, true

    if result.__bracketContext
      # First see if there are any brackets to forward. We need to reverse

      return unless @isForwardingOutport inport, name
      # We have already forwarded this context to this outport
      return unless ctx.ports.indexOf(outport) is -1
      # See if we have already forwarded the same bracket from another
      # inport
      outContext = @getBracketContext('out', name, ctx.ip.scope, index)[idx]
      if outContext
        return if outContext.ip.data is ctx.ip.data and outContext.ports.indexOf(outport) isnt -1
      forwardable.push ctx
    return forwardable

  addBracketForwards: (result) ->
