Sorted out the rows that were not being removed from the image tables when a image was being deleted