@jackie_w - Thanks for testing--hopefully it continues to work for you.
As for the opf & ncx, they're being created completely anew, not copied and modified. While working on earlier projects, I found that trying to pretty print those files from my constructed DOM caused problems with excess whitespace in the text data, like ToC entries. At the time, I didn't judge it important enough to put more effort into.