Fix up some error handling