Optimize expression tree generation code