Minor tidying and improved documentation in the leader comment.
Registering exception handler for each thread, rather than the whole task.
This avoids the need to forward exception messages to the debugger, since we can reasonably insist that we're the first handler in the chain for each thread.
Lots of tidying up, deleting unnecessary code, and adding documentation.
Catch-up merge from master to macosx-threads branch.