Refactoring to new structure mostly done.

Changes in TH code are pending.