Fix entity numbering.

Had to fix a number of related tests.