Masters in math, bland PhD in CS, want to go back to math All of the following is in Italy.

I have a master's degree in mathematics and at the moment I'm in the final months of funding in a PhD in Computer Science (not sure if I'll be able to finish my thesis in these months).

I'm in this PhD due to a series of unfortunate circumstances and mistakes on my part, fact is that I am totally unhappy with where I am and I'd like to plan on the best way to go back to doing mathematics.

The reasons that I'm unhappy with my PhD are:


lack of interest in the subject (basically a very out-of-trend subfield of Natural Language Processing, more like a one-man project that my advisor started a few years ago and keep pushing it but never took off, which I instead thinks is a dead-end and the community seems to go in other directions);
the fact that my PhD is totally unstructured, by this I mean that there was never a clear plan of action, no courses to take, no real training at all, and no real topic for the thesis, just relatively uncorrelated publications that now I find difficult to unite in a thesis; for the same reason there was no possibility of changing advisor mid-term, nor there was any help like a career center or similar structures (I actually discovered the existence of such things on this site). also there is no formal recording of my experiences (for example as a teaching assistant) so there is not much I can show for this three years;
last, I plain and simple find out that I like mathematics way more and I miss it a lot.


So I would like to ask opinion about what is my best course of action given that:


I have a rather uninteresting CV: master's grades are not bad but most are in courses not pertinent to what I'd like to do; moreover my master thesis was not strictly mathematics, but was done with the professor that later became my PhD advisor, and I fear that not having done any mathematical research is a serious problem;
As mentioned before there is not much I can show for the three years of my PhD: no transcript of courses, no formal review of my work, just a few publications and the word of my advisor, with whom I don't even have a great relationship;
I never spent time to create a network, I don't know any other professors to which I could ask for letters of recommendation;
by the time I'll have finished my PhD I'll be 30.
The main thing you will have to show for the three years is your thesis, so the first objective should be to finish it on time. If you feel the project is at a dead end, maybe you can target making your thesis the capstone that closes it out. Turn your papers into sections each of which resolves a loose end. That way, it does not matter if they don't relate to each other.

Meanwhile, can you audit courses in the mathematics department? Get to know some of the mathematics professors, and get their advice on how to transition.

Don't feel too old - I was 60 when I finished my PhD, and I'm still learning new stuff. You have decades of research in front of you.