Database abstraction fixes