Transformed to in-place inversion. Added singularity check.