Refactor study reporter; handle file/writer cleanup.