Some rework in how environments are handled