merge search performance improvement code from master