Fixed delete function.