Expand the pack/unpack API, implement unpack flags