encacpsulate duplicated sorting of episodes into method and other minor refactorings