Fix up error handling a bit