Fixing graph, cleaning code