Dh/refactor plat header v2

Rebased Dan's refactoring work on the top of the other v0.4 features.

The last 6 commits contain the refactoring efforts.