Error handling
Properly calculate the next seq number
Debugging helpers