Refactored db interface into CapoDB