document no longer has matchesSelector

Changed the many references to window.document into a `doc` shorthand.
Added counts on all the new methods.
Added the missing semicolons in the original.