added graphs, cleaned up some code