Bug fixes to creating a graph