enable metadata only search and more refactoring.