Improved expression tree builder, fixed #5 memleak