Fixed more bugs in packet handling.