Improved db abstraction