Improve infrastructure for subgraph command