Yet more cleanups and refactoring prompted by Jenkins