Shorter classes

Refactorings to make the longest classes shorter, plus a couple of other things I found along the way.