Minor fixes

Created variables from functions so that they are not conditionally defined. Also passed in a window var to aid in further minification.