split code into smaller reusable functions

 1) Move constant vars in config.py
 2) split connect functionality from search.py to connect.py
 3) improvements in docstrings and actions