fix bug in merge subgraphs
merge master with fixed subgraph bugs