Fix document display code

Fixes GH-1. Also a bit of refactor in the DocumentView class.