Rearrange ending table code.