Fix bugs in read_data.