Attempting to fix sqlite threading issues