Added caching of the latest search term and trimming of it.