Further testing shows that the code you provided skips some commands. Like the buffer doesn't store the messages properly.