Fix environments

A continuation of #544