I am implementing from scratch an Hartree-Fock calculation in the STO-3G basis set to perform Born-Oppenheimer molecular dynamics. I have a Restricted Hartree-Fock procedure that can reproduce very well the total energies of Ref.  and of Gaussian09 with pre-optimized molecular geometries.
Now, during a Born-Oppenhaimer MD simulation, I will have geometries that can be quite far from equilibrium. I saw that my SCF cycle does not converge for stretched geometries: the SCF cycle for the $CO$ molecule with a bond length of 2.132 bohr converges, while for a bond length of 3.132 bohr I reach the maximal number of allowed iterations (500).
In Table 10.4 of Ref.  it is clear that an implementation of the DIIS (Direct Inversion of the iterative Subspace) method speedup the SCF convergence. In addition to this speedup, it seems that the convergence for a stretched molecule can be easily reached with this method. For this reason I implemented the DIIS algorithm following Ref. .
I believe I implemented the DIIS method quite correctly, since I was able to obtain a speedup of SCF convergence for pre-optimized molecular geometries. In the following table you can find the number of simple SCF and SCF-DIIS steps I have, for different molecules:
Molecule SCF DIIS H2O 16 9 CO 53 19 HeH+ 8 7 CH4 11 8 FH 10 7 O2 41 18 N2 110 22
In every molecule I tested I get a speedup, which is quite impressive where a lot of normal SCF cycles were needed. This is a good result, but unfortunately the convergence of stretched molecules is not improved. By doubling the distances (in bohr) of the pre-optimized structure, the DIIS algorithm (as well as the normal SCF) fails to converge.
There is some step to add to the original DIIS algorithm of Ref.  that I am not considering? How I can make the SCF cycle convergent for stretched molecules, provided that these calculations converge in Gaussian09?
Gaussian09 brakes down as my program does with the option
SCF=NoDIIS. With the option
SCF=DIIS the SCF converges even for very distorted molecules.
 A. Szabo and N. Ostlund, Modern Quantum Chemistry, Dover, 1996.
 T. Helgaker, P. Jørgensen and J. Olsen, Molecular Electronic-Structure Theory, Wiley, 2000.
 P. Pulay, Improved SCF Convergence Acceleration, Journal of Computational Chemistry, 1982.