Fixed handling of scaled vars

Replace now works for variables that are transformed in the equation
with parantheses