Implemented stack traces

I rebased patches and refactored some files as discussed at meeting. (see also pull request at shims)

I'll be reading the code and adding inline comments/questions. @luite it would be great if you could review and post inline comments if you're not happy with some parts. It'll be easier to track changes this way.
We have lots of code like `decl to <> [j| `to` = ... |]`, I think we can replace that with `to |= ...` but I'm leaving that to another pull request.