some fixes of global/local variable access