Nice write up! I'd caution just checking for an exactly-zero determinant. Read up about ill-conditioned matrices, and maybe check that conditioning number (or a determinant below a certain threshold) first. Also, work hard to never, ever have to actually fully invert a matrix.