Combined into a single file as an experiment

Also, inlined all serializing.