fixed a lot of bugs in graph.js