Fixes bug when deleting images