fix writing external references to already externally referenced bodies