fix bug in VariableVisitor
 fix bug in Replace
 add a restore method in Replace