Sqlite3 handler and other refactorings.