small changes in how data_length is calculated