Fixed bug in which removing an image would result in errors