Various changes that probably should make it upstream

Except for the HTML5 media element disposal.

@eleith