more code reorg, and wrote another naive packer