Added improvements to exception handling and event handling.