Update ref temp removal code to deal with original vars that are refs