Fixed up bugs in parsing HTML
(thanks to Secrets of the JavaScript Ninja!)