It's a bit unfortunate, but getting a substantially cleaner, safer SF would require a cultural shift away from egalitarian principles that are deeply ingrained in the city's DNA.
Note that while downtown Manhattan is approaching a dystopian Disneyland of tourist-friendly homogeneity, there are still parts of the city that are scary no-man's-land, you just don't see them if you visit or live & work in gentrified neighborhoods.
Back in the day, NYC was nice or nasty block by block, just like SF is today.