Change API due to exceeded sequence number.

It is not likely to happen, but check for the max sequence number is added.
API changed, in case the sequence number is exceeded, an error is returned.