add support for setting an error handler
fix code for enabling multi-threaded async message handling