Optimize exception handler. Add support for passing parameters to new threads.