Added serialization and a metric ton of internal validation to help
test it