Massive javascript refactoring and moving to graph.js