First round of refactoring

This probably doesn't work at all, so don't even try. However, this
includes most of the changes that need to be done to adapt the
extension to work with click-to-play instead of remote XUL.