Clean upenvironment code to prepare for minimal-cropping.