Refactor global variables