Added 'manual' computation of the determinant of a 3x3 matrix to improve speed.