Permalink flakiness

Here are the fixes for #354, on top of the new jsonld.js changes from @dlongley.