Fix a number of problems with graph generation