Fix custom queries list.
Add custom queries for documents.
Fix some error due to previous refactoring.