If your dog does something you don’t like, there’s an elegant way of getting rid of that behaviour. Most people don’t know about it, and I certainly didn’t until I read about it in Karen Pryor’s book “Don’t Shoot the Dog”. The method is: put the unwanted behaviour on cue, and then almost never give that cue.
As an example, if your dog barks at night or at random people, you can teach your dog to bark on command. And then only give the command sometimes, in a controlled setting, to reinforce it. The behaviour will disappear when the command is not given.
I wish my neighbors knew about it.