Rework SQLite again to use thread local connections - closes #492