Replace ad-hoc identifier cleansing with helper function

Generalized identifier cleansing to replace invalid (and unicode)
characters with underscores to ensure a valid function name.

Applied function in other places functions were generated based on
libarary name.