Further cleanups to texture caching, from bug 523: