Redesigned expression rewriting... hopefully for the last time...