Significant changes in data marshalling/unmarshalling.

Instead of reading and writing data directly to structs, now each field
is individually read and written in order to avoid alignment problems.