Updated implementation of CacheMatrix by Daniel Marcous