Add BDB read and write functions