Fixing a few bugs in expression tree generation