Abstracted code bits in db.c