Reorganize and use the ImageViewer class.