Various enhancements

Servo's Rust is too old to build this code, but I want these changes for html5ever.

We can update Servo's submodule after the next Rust upgrade (which is already needed to land html5ever).