Few fixes in deletion function