Support reference uri & fix gobs of C code

A comment explaining what are the 3-4 arguments or why there are 3-4 arguments will make this code readable in the future me thinks.