Revert "Rewrote order numbering code"

This reverts commit fd75dbd2fdb8babc2b6e7e9ca294597a9186bb8b.