Fix bug in deleting temporary records.