Fixed some bugs with viewer.