Use safe-string and fix some deprecation warnings.