Rework ref rewriting
Roll back rewritten refs if rewriting fails
Fix MetaFixture