bug fixes in packet encoder