Added search logging and suggestion, also some refactoring