Smarter fix for #810, since not all 24-character strings are like MongoDB ids.