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.
TODO: `allocCon` already checks for profiling flags so no need to pass `noCCS` here.