Refactored out some globals