Support reference uri & fix gobs of C code

This is all new code! No gotos! :)