Fixed the two most obvious entry points (actually making a linked ID local, and making a local copy of linked data), there may be more unusual ways to do that still hidden in the code though. Also added a couple of 'sanity asserts' to the writefile code regarding cases where IDs are expected to have a null deep_hash data.