Moving require and thread isolate globals to environment.h