Refactored code, fixing issue where global variables were not looked up. Possibly breaking changes bumps to 2.0