Fixed issue with using sqlite accross threads