Refactoring to separate out sequence numbers and remove dead code.