Detecting and correcting loss of independence in nonlinear conjugate gradient