Refactor to reduce number of global variables.