Major refactoring associated with episode 11.