Refactorization: Avoid string copying.
Refactorization: Changed simplifyMathFunctions() to a single pass simplifier