Add sqlite3 hook, fix encodings issue and update license header in tests.

and a couple of other changes.