Move some globals into main thread scope