Include search terms in recommendations and some refactoring