 
     @checkTransactionStart()
 
+    before = clone node.metadata
     node.metadata = {} unless node.metadata
 
     for item, val of metadata
       node.metadata[item] = val
 
-    @emit 'changeNode', node
+    @emit 'changeNode', node, before
     @checkTransactionEnd()
 
   # ## Connecting nodes

    return unless @inports[publicPort]

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

  addOutport: (publicPort, nodeKey, portKey, metadata) ->

  # 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
