Rewrote more code in the urls module to work better on python 3