Improved robustness in threads by catching all exceptions and logging them.