Added functionality to cache inverted matrices