Trying to make error handling more robust.