Viewer state refactor

addresses #41