Refactor EpisodeManager and include clean-up code