Optimizer bug fix