Improved 404 support

Improved support for documents that are missing or don't exist.