Improved Sub Expression Folding. Really needs some code clean up though