Use pack_from/unpack_from and offsets.
A few tiny performance improvements

Tidied up the serialize methods a bit, and also the pack / unpack parts
of the code.