Matrix inversion caching added