Rehauled imageviewer code