Support reference uri & fix gobs of C code

Should you be using StringValueCStr here instead of strndup? I'm looking at: http://stackoverflow.com/questions/10210624/how-to-convert-a-string-taken-out-from-a-ruby-array-into-a-c-c-string but am otherwise unfamiliar with C extensions for Ruby.