fixed some bugs
added functionality for keys.
key changes make the graph look kinda ugly, but it's much closer to
being correct.