Bug fixes for Documents