Fixing bug in Optimizer.