cached matrix inversion working; todo: cleanup