Support reference uri & fix gobs of C code

Nice catch! For free(), NULL as an arg is definied to be no-op by the standard so we're okay there.  For xmlFree*(), I looked around and that seems less certain...there's some forum posts saying the API officially says you must not call it with NULL (grrr). Good thing is with your StringCValue() find, all the free() calls just went away (yay!).  I looked at the xmlFree bits and they all seem to wrapped with a NULL-ness check so I think we're in the clear.