Created proper cleanup for graph struct.