images: Moved some functionality into models.