Optimize segments when generating helpers