Improve migration optimizer to be able to optimize through other ops