Added expansion and contraction of images. Refactored a little.