graph optimization caching made better