Cleanup globals usage to avoid cyclic dependencies.