Improve exception handling; validate content-type

Since we're spawning a number of asynchronous processes, we have to be
careful to abort the program if any of them fails.  This patch
introduces a number of "link" calls which ensures that any exception
is propagated immediately to the process that spawned the process.

In general we want to abort as soon as possible to avoid producing
incomplete output.