Impelment record serialization.

Closes #9.