Optimize traces