I've had a lot of the same struggles. It goes in fits and starts. One thing I might recommend that helped me a lot is to look at your diet and exercise. Sugar cycling was always a big problem for me, and eating junk food will slow you down a great deal. Sometimes when my mind is restless, a bit of exercise will help me focus.
Good luck and keep at it. You're not alone. These pursuits are valuable because they are difficult, and unfortunately it comes with the territory to some degree. Just keep at it, and the more you reinforce good habits, the easier it will become.