refactor some bugs out of UrlFactory