Fixes to graph generation code