Fixed to append leftovers into last group instead of a too-small group