Attempt to fix error handling

Do we need to assert here at all?