Put the typeMap generation into its own function.