Tweaked sqlite threading