Added function get_document + small fixes