cleanup to core code for handling new env