Corrected a couple of serious bugs in the viewer