Generic packing and unpacking library.