Fixed function hoisting. Modified the way globals are implemented a little bit.