Fixed usage of global variables.