[FIX] GUI: Shift-Tab in empty editor caused an error
[MIN] cleanups
[FIX] XQuery: revised computation of document order. Closes #588