Fix bug when destroying records.