Deal with global variable in batch functions.