Rewrote most of the IO design.

Beware, outputs from older formats will no longer be at all compatible,
unless you decide to write a converter.