Handle API errors and pickle better.