Optimizer updates. Almost ready to test I think.