Migrated unpack.py to OCaml