Fixed a bug causing the images to be deleted too soon.