small error checks and rewrote packet.GetBytes