[MIN] Cleanups
[FIX] XQuery: replace first document in a database. #1034