Added some code to ChangeVariables to improve the substitution of the new
variable into function arguments.