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).
It's in relation to this - https://github.com/rust-lang/rust/issues/16738