Improvements in searching and QImage loadings

- doing db queries in the main thread
- making the code more readable