stackcache: A little restructuring and some fixes.