Refactor, and get rid of the dependency on the url package