Canonical serializer support

Fixes #1, #2