Small refactoring of graph builder.