Fix broken HTML elements and unescaped entities