bug fix in packet reader/writer