Code cleanup

r?
I started running tests with the `-3` and `-Wd` options (Python options) and that brought up warnings and 2to3 issues. The `-Wd` showed a bunch of deprecation warnings from Django. I'm pretty sure we should fix all of these, but I didn't look into it much more than that.