Changed delete function a little bit.