Fixed a bug in function application

There was a bug where the environment was not restored after finishing a function application, but where evaluation continued in the environment of the function that was applied. This bug should now be fixed.