Refactoring cleanup and working global variable creation.