CONTRIB-5351 fix preg usage
CONTRIB-5403 fix errors from orphaned surveys.