Fix handling exceptions