Functions defined without being declared.

Major breakage.
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.
Merge pull request #604 from matthewp/undeclared-funs

Functions defined without being declared.