Fixups and refactoring.