ensure package name valid while minimizing mutation

Here's a variant of the package name sanitizer that minimizes mutation of the name.