Fix bug in episode calculation

Fixes #7.