I don't understand the following equality:
\begin{equation} x'\frac{\partial x'}{\partial q'}+y'\frac{\partial y'}{\partial q'}+z'\frac{\partial z'}{\partial q'}=\frac{\partial}{\partial q'}\left(\frac{x'^2+y'^2+z'^2}{2}\right) \end{equation}
Here, $x'$ represents the derivative $\frac{d}{dt}x(t)$. Maybe I'm getting lost with my chain rule.
This follows from $$\frac{\partial (x^2)}{\partial q} = 2x\frac{\partial x}{\partial q}$$ Now you just replace $x$ with $x'$ and $q$ with $q'$ in this formula, and do the same with $y'$ and $z'$.