Handle asynchronous uncaught errors with domains

Fixes #155, #177, #279