Make generaterealdata more robust to save errors.