Small cleanup of image handling