Added code for the inverse mat caching functions.