Added code for computing and caching matrix inverses.