Fix service logging, fix potentially opening the database from wrong thread