a few minor bug fixes when generating graph