tidy up defensive environment initialization