@vertigo
I've messed around with the McCLIM code that handles this, and it's somewhat messy. It's not an easy problem to solves, and McCLIM do get it wrong when you do complicated stuff.
However, you always need to understand the underlying architecture. The abstraction will only take you so far and you often need to manually dig in the output history