Added database handling routines