Changing PhD area of math?
There is one piece of advice that seems particularly important to give: do whatever is needed to enjoy working on your PhD. You won't go very far if stress and pressure is all that gets you going, and the probability of getting an academic job after even a very good PhD is too thin to go into PhD without enjoying the PhD years by themselves.

Of course you will have to work hard whatever path you take, and not all the work will be pleasant. But if you are not enjoying your current work at least from time to time, you should definitely change something. Having insufficient foundations is a pretty good explanation for not enjoying oneself, so going to a subject where this problem will disappear feels reasonable to me.