More refactoring following up on Jack's suggestions about classes inside classes.