Folding: Fix bug with empty documents