The way for the clerks to avoid such an occurrence is to pay attention and do their jobs. The laziness and slovenliness of the clerks causes backups at the checkpoint, which creates a concentrated target for a potential attack by keeping the passengers from dispersing throughout the terminal. So what the clerks need to do is:
Learn the forms of acceptable ID
Learn what is and isn't a potential hazard and how such things appear on the X-ray
Stop retaliatory screenings
Stop wasting time and slowing down the line by arguing with passengers about filming
And, generally, do their jobs in a conscientious manner.