Fix role slugs not saving

I swear I tested this, but it would appear as though I didn't. Arguments in array_replace_recursive were reversed. Plus other fixes below.

* Improve slug sanitization logic to reduce the risk of an empty slug
* Also improve rewrite tag logic so we're not adding duplicate or empty strings