Structural change plus bug fix in the optimization