Fix a bug in the optimizer.