improved organization of code with GraphAid, more comments, cleanup