Tidied up graph code.