Added db abstraction. SQLite is about 1s faster (total time 5s) than TDB.