Some fixes in the optimizer.