added d3 library
tidied up main controllers and templates