Added defensive code to search functions. Set results to null when no results found.
Encoding queries before search.