The newEnv variable was accessed (via the dynamicEnv) pointer after it had gone out of scope. Fixes #234.