Fix various bugs.

Some variables were misnamed, and export_sizes() contained a few errors
in its row writing operations.