update of optimization routines
Optimization: improvements and new functions