improved handling of ill-conditioned cases