More refactoring ahead of database option.