Added listmap to use for graph. Code cleanup. Fix bugs.