Made the orientation a bit more robust to non-orthogonal matrices