Partial checkin of database refactoring.