Moved global variables to globals infrastructure.
Some global variables resolved, some moved to globals infrastructure.