fix thread unsafe environment preparation