Partial implementation of the optimization mode.-