redo big_endian bitfield packing in a simpler and more correct way