bug fix in graph and clean up