Move Expr.replace, rewrite, and apply into the prototype where they belong.