Various optimizations in the ML code.