db layer improvements