Added debugging, fixed a potential problem with packet sizes, and
removed dead code.