Refactor corpus reader