Massive overhaul of final formatting

Final output is now broken into chunks for better MM formatting. There
are still issues with splitting lines in the first half, but that is a
work in progress.