Added exception handling in callbacks.