Race condition fix. Global variable name fix