Optimize stack usage (#409)

This should fix or improve #409 - don't exhaust stack before recursion is detected.

TODO:
* [x] Pass Value objects using shared_ptr instead of by value
* [x] Throw and catch exceptions on function recursion detected
* [x] Detect recursion by measuring stack usage instead of a recursion count
* [x] Look at the corresponding module recursion behavior (See #1007)
* [x] Investigate memory leaks triggered by exception unwinding skipping delete's of dynamic memory
* [x] Consider allowing expression evaluation to be cancelled from the GUI (or open a new issue on that and add loop limit to the loop in the tail-recursion evaluation) -> See #1049 
* [x] Check the (simple) implementation of tail-recursion elimination
* [x] Function recursion is probably caught in the wrong place, causing cascading recursions. Look into this.