Assorted random cleanup

There are a few little bits of messy code and a couple of deprecated Twisted APIs. This branch is to clean those things up.