Great to hear it worked out for you

. From my limited experience with making ebooks, I'd strongly recommend doing whatever it takes to fix the text before working on any formatting. That way you can export the text to any other text editor/word processor of choice, fix things, and then paste it back in and go about with making Titles and the TOC.