some necessary refactoring, mopping up a bit of dust, and removing some duplication