Split lines on words, fix headers and references