db.cpp library fixes (first try)