Add handling of unexpected exceptions