additional refactoring of backup code.

slowly this is getting manageable and extensible.
more backup code refactoring

attempting to get the backup code to be extensible.