Fix new viewer and some bugs