Fix threading related SIGSEGV in sqlite3.

The SQLiteModelStore used Model.SyncRoot to guarantee that only one
thread could access the given connection at any given time. However,
that did not work for the enumerating API we have for SQLite, meaning
that whenever we were querying something, the lock was released and
other threads could start their own queries.

If two threads happened to access the sqlite connection at the same time
a segmentation fault was caused.

There was no elegant way to hold on to the lock until the querying was
done, thus the only way to solve this problem was to introduce a thread
local database connection.

Closes #51