Significant cleanup for generic URI code

Signed-off-by: Harshavardhana <fharshav@redhat.com>