some more care in row_number. closes #781