Bug fixes for looping in graph.