Fixes on the cache building functionality