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.
I need to fix this part: `ccId` should not be passed when not compiling for profiling.