fix some HTML parsing bugs