db refactorings

Change-Id: I19a1f067f0c59517afaeaf844621de5409f9c24e