[DONOTMERGE] Improve Python 3 compat, clean up code

Further improve compatibility with Python 3 by making the `urlparse` import
conditional.

Make some sed expressions use "|" as a separator instead of "/", thus allowing
all occurrences of "\/" to be removed.

Update some comments and shuffle around code to make it more compact and
readable. Add some FIXMEs.
Hunh. I just spent a bit of time reading the man pages for `git clone` and `git init`, but couldn't decipher any particular reason for adding `.git` to a directory name. I'll chalk this up to me just being ignorant of the subject matter.