Fix env changing bug and improve performance of workers