Split the data reading code into its own file, fix it, and polish the rest 'til it shines.