Fixes variables attached to the window.

This fixes a few instances where variables were being attached to the window that are meant to be used only locally.