Bugfixed getDocument, getDocumentTree. Refactoring all apis to validate input params.