More refactoring and implemention of additional database operations.