Substituted echo commands in generate.sh with printf commands because they do less harm. Also added function to translate type name back into type id.