Guess mimetype correctly, and a few other small changes

Hi folks, love the library! I found it was annoying to always have to manually specify application/xhtml+xml for xhtml documents, so I added that; while I was in there I put in a couple other little changes too.

Cheers,
Tom