refactoring. added dbs instance. fixed thread-safety (globals) in search.py;