Use message UID instead of sequence ID

Sequence IDs change as new messages come in, which makes them unreliable
identifiers.