Refactor db.h