It's great to see this function refactored, but i would go one step further, and separate each of the remaining sections in separate functions in this module.  For instance: `process_source()` doing the things in `# Starting source processing`, `process_dataset()`... there seem to be neatly separated sections, but maybe i'm missing the overall structure...