Refactoring how the graph and nodes are created