Rewrote expressions and added flatten-expression.