Handle sequence number wrapping.
Various pieces of brilliance