Factor out corpus.js from main.js