Some expression tree rewriting for better compilation