Code style & threading changes

Changed the code layout
Moved the search function to a separate thread for GUI responsiveness