Bugfix for global variable issues