Fixing the memory leak/reference removal on delete/remove.