     return unless @inports[publicPort]
 
     @checkTransactionStart()
+    before = clone @inports[publicPort].metadata
     @inports[publicPort].metadata = {} unless @inports[publicPort].metadata
     for item, val of metadata
       @inports[publicPort].metadata[item] = val
-    @emit 'changeInport', @inports[publicPort]
+    @emit 'changeInport', @inports[publicPort], before
     @checkTransactionEnd()
 
   addOutport: (publicPort, nodeKey, portKey, metadata) ->

    return unless @outports[publicPort]

    @checkTransactionStart()
    @outports[publicPort].metadata = {} unless @outports[publicPort].metadata
    for item, val of metadata
      @outports[publicPort].metadata[item] = val
    @emit 'changeOutport', @outports[publicPort]
    @checkTransactionEnd()

  # ## Grouping nodes in a graph

  # This method allows changing properties of the graph.
  setProperties: (properties) ->
    @checkTransactionStart()
    before = clone @properties
    for item, val of properties
      @properties[item] = val
    @emit 'changeProperties', @properties, before
    @checkTransactionEnd()

  # ## Exporting a port from subgraph
