Code changes for cache matrix