Changes to duplicate environment behavior

The main function instructions should not be copied, but the global
scope should be shared between the environments.