Handle Malformed URIs Bug

I like your modularization @Renelvon , only that I'd take those functions outside and make them public as they're quite useful.