       if ip.type is 'closeBracket'
         # Bracket closings before data should remove bracket context
         @result.__bracketClosingBefore = [] unless @result.__bracketClosingBefore
-        context = @nodeInstance.bracketContext[@scope].pop()
+        context = @nodeInstance.bracketContext[port][@scope].pop()
         context.closeIp = ip
         @result.__bracketClosingBefore.push context
         continue
       if ip.type is 'openBracket'
         # Bracket openings need to go to bracket context
-        @nodeInstance.bracketContext[@scope].push
+        @nodeInstance.bracketContext[port][@scope].push
           ip: ip
           ports: []
           source: port

          return unless buf[0] is ip
          # Remove from buffer
          port.get ip.scope
          context = @bracketContext[ip.scope].pop()
          context.closeIp = ip
          return unless context.ports.length
          debug "#{@nodeId} closeBracket-C #{ip.data} #{context.ports}"


    # Add current bracket context to the result so that when we send
    # to ports we can also add the surrounding brackets
    @result.__bracketContext = {} unless @result.__bracketContext
    @result.__bracketContext[port] = @nodeInstance.bracketContext[port][@scope].slice 0
    # Bracket closings that were in buffer after the data packet need to
    # be added to result for done() to read them from
    return dataIp
