Detecting and correcting the loss of independence in nonlinear conjugate gradient