Grouping line items, fixing order bugs