Bug fixes to pass around the proper env