Fixed small scope bug when removing variables.