fixed bugs in packet mode