More robust exception handling