Quite a few changes to fix bugs I'm finding as work through parsing the files.
Few more small fixes. But one big problem remains for some badly formed pages.