Changed how _document is created so we can do type hinting