That's the spirit.
It sounds like friendship with M is something you can do, you probably don't have to erase her from your life completely but you also know if you get too close to the situation you lose a bit of your cool.
The situation sounds promising, there may be times when your emotions say different, but at least you've worked it out in your mind. I consider it somewhat of a (fortuitous) coincidence that you met M when things weren't going so well. She helped you jump-start your life. Now you know you have your own batteries you can run on too, so things are different than they were back then.
Things will keep getting better, I feel confident about that.
Love means never having to say, "Put down that meat cleaver!"