Bug fixes + improvements for document selector