Final version of dynamic env. mapping

Needs still full test.