Repair asset writing

Gradually fixing the features that were broken by the output rotation work.
Then I can move on to refining the rotation.
Fix up rotation

TBH it's been a few months since I looked at this, so I've just made the tests
pass as I try to understand what I was doing...