Some refactoring related to viewing images.