Fix issue with heand and tail of HTML document
Merge concurrent changes.