changed update_energies setback function, added debug ouput for residuals