Support reference uri & fix gobs of C code

In 'done' you call free() on keyName and refUri. I forget - is that going to be a problem since they are NULL at this point?