cleanup code for Graph