Use standard loop to avoid recursion error.
Merge branch 'cache-cxx' into cache-cxx-flatgrid