A couple of refactorings suggested by flog.