Refactor preferences in viewer