Bugfix: the prototype was being restored incorrectly to the env object, as opposed to the original function.