Modification to database related functions. mostly minor.