More general variable substitution.