Added a separate sqlite thread for data logging