Tidy graph code a little