more efficient minimization and integrated Etiennes code