Global variable bugfix