Bug fix: accidental global variables