Also, I'd love to see the whole `# Generating the filters for versions` section broken off as a separate method. This one is getting pretty long, and there's a lot of state flying around in there. A casual look suggests it'd be pretty easy.