Fix option handling, allow an id to be used as a document selector, and add helpful error messages.