Converts to use Masterminds/HTML5 instead of local copy

Also adds support for passing DomQuery objects to several APIs.