ENH/CLN: Clean up batch code, and save meta info in yml file.