Optimized a bit optimize()