Use the global scope for environment lookup

Modules sometimes have their own "environment" variable, which prior to this change would get looked up by module_data and cause an error. I believe that when module_data looks up environment it really means ::environment.

Obviously modules shouldn't be using the environment variable for their own ends, but this patch makes module_data work with those modules as well.
let's do a cleanup commit / pr separately.