Replaced an uggly for by a bit less uggly while for the matrix inversion.