Refactor the uri cleaning