Handling empty documents

Possible solution to #60