introduced global level variables in environment and mappings

this fixes bug of auto-mapping
I tried to make as less changes as possible (UserEnvironmentGenerator logic is difficult to understand)