Move legacy code to new structure.

Addresses #2210