Improve the code quality of the metadata generation routine.