Move URI builder into its own class and refactor.