Correct index errors in packet decoding