Clean up the dataset generation script, improve the subdivision id generation code.