cleaned up code, added dedicated graph class