Fixing global variable namespacing, & arguments in functions