rearrange code in bbox_sort, add reminders in comments