DIIS addition, code clean up