refactoring to support backup/restore