Now with caching to speed up the sparsify and densify process