Added data_end handling