Initial refactoring of database functionality into the manager and server.