Optimize the "delete" function.