Removed globals, modified function names