Refactored view logic so that every document has it's own saved view state.