Database: move some code to details, rename member functions.