Some code review

None of this is very significant yet–it's mostly just small refactorings. I have a few slightly larger changes in mind, more along the lines of dnolen's suggestions, so we'll see what comes of that. I'll push to this branch, so don't merge.