Makecache improvements

Two patches for makecache (not actually tested, but they're pretty simple...)