The event phase AT_TARGET should also fire events registered with capture=true on the event target, not just capture=false.

See #855

This pull request also fixes two smaller issues that I found while making my changes.


Jeez, we apparently have lots of nonstandard APIs. I'll fix this later.