ENH: Improvements to pass environ variables to shell to control threads