Updated matrix inversion functions.