Although I haven't applied for PhD yet (only for masters so far), I'll speak my mind, as I am applying this year...
My personal take is that the most important part of your applications is the LORs. I believe the best strategy is to ask professors who know you well, preferably ones you have worked with (e.g. for a thesis etc.) and who can speak well about your potential to succeed in your chosen field of research. Of course, it helps a lot if these professors are well-known and have exellent research, but I think that it's a bad choice to prefer a "famous" professor who cannot speak about you in detail and will resort to generic comments instead of a less well-known one who knows you really well and can make detailed comments about your skills.
If you can do some research before applying that's great and I think it will help a lot with your application. Especially for pure math, it's not that common before PhD, so it might impress the admissions committee and it will probably help a lot, especially if you have a bad record somewhere.
I do not think that 1-2 bad grades are that damaging, especially if they are in low division courses taken in the first 1-2 years and you can justify them in your SoP. But I think grades in advanced/graduate courses are much more important, and doing bad on them might hurt your chances. At any case, if you can justify a bad grade you should do so in your SoP, but don't devote too much space into it and certainly avoid providing excuses (i.e. do it only if you have a serious reason which does not objectively look like an excuse, and which you can support with evidence if asked -e.g. if you had documented family problems or an illness or something).
For the choice of schools, you should first think about what you want to do (not very specifically, but not too generally either) and then ask around professors from your department. Some might recommend less well-known schools that are excellent at your specific field of choice, and where you'd have greater chances of getting in.
As for your timing, I think that you should aim to ask your letter writers at the very least one month before the date you plan to submit your application, although of course the sooner the better. Keep in mind also that most professors are really busy, so you may need to remind them once or twice, so plan ahead. Don't be afraid to ask if the professor can write you a good
LOR; if s/he cannot, they will tell you so, and like I said a mediocre LOR migh hurt your application a lot.
Regarding deadlines in general, I think that it's best to submit your application at least 2-3 weeks before the stated deadline, especially if the school has a rolling admissions process (where of course it's better to submit it as soon as possible as the later you are, the less chances you have of getting in). Transcripts probably need to be mailed directly from your registry, so I'd recommend asking for them at least 4-5 weeks earlier for US students and 6-7 for international ones.
Finally, regarding GRE, I'd say take it at least 1-2 years before applying, so that you can retake it if necessary.
Of course, that's all my personal opinion, I may very well be wrong