Faster opt

This make the gpu optimization faster. In one case, the full optimization process was taking 611s, now 364s.