tidy up of packet parser