Fixes to pkt-gen.c

See commit comments.