Make sure that the doctype is first thing on the page.
Cache the regex and remove logging.
Merge pull request #601 from remy/fix/doctype-600

Doctype fix