Fix a few global / local variable shenanigans