fixed environment handling from primitives (?)