fixed disappearing query in the search box
minor refactorings