serialization hooks. Fixes #16