I am trying to follow a proof if Ramanujan that states $$ \sum_{n \leq x} d^2(n) \thicksim \frac{1}{\pi^2}x (\log x)^3$$ as $x \rightarrow \infty$ where $d^2$ is the square of the divisor function. At one point in the proof, we arrive at \begin{eqnarray*} \sum_{n \leq x} d^2(n) & = & \sum_{\delta \leq \sqrt{x}} \mu(\delta) \left( \frac{x}{6\delta^2} \log^3 \frac{x}{\delta^2} + O\left(\frac{x}{\delta^2} \log^2 \frac{x}{\delta^2} \right)\right) \\ & = & \frac{x}{6} \sum_{\delta \leq \sqrt{x}} \frac{\mu(\delta)}{\delta^2} \log^3 \frac{x}{\delta^2} + O\left( x \sum_{\delta \leq \sqrt{x}} \frac{1}{\delta^2} \log^2 \frac{x}{\delta^2} \right) \end{eqnarray*} where $\mu$ is the Mobius function.
My first question is how the summation gets absorbed into the big $O$?
Next, we estimate these sums separately. The first term is \begin{eqnarray*} \frac{x}{6} \sum_{\delta \leq \sqrt{x}} \frac{\mu(\delta)}{\delta^2} \log^3 \frac{x}{\delta^2} & = & \frac{x}{6}\sum_{i =0}^3 {3 \choose i}(-1)^i \sum_{\delta \leq \sqrt{x}} \frac{\mu(\delta)}{\delta^2} \log^{3 - i}x \log^i \delta^2 \\ & = & \frac{x}{6} \left[ \sum_{\delta \leq \sqrt{x}}\frac{\mu(\delta)}{\delta^2} \log^3 x + \sum_{i = 1}^3 {3 \choose i} (-1)^i \sum_{\delta \leq \sqrt{x}} \frac{\mu(\delta)}{\delta^2} \log^{3 - i}x \log^i \delta^2 \right] \\ & = & \frac{x}{6} \log^3 x \sum_{\delta \leq \sqrt{x}} \frac{\mu(\delta)}{\delta^2} + O \left( x \log^2 x \sum_{\delta \leq \sqrt{x}} \frac{\log^3 \delta}{\delta^2} \right) \end{eqnarray*}
My second question is, once more, how does the summation get absorbed into the big $O$?
After addressing these details I think I can work my way through the rest of the proof, but I am new to asymptotics and having a hard time understanding these steps of the proof. Any general info about asymptotics and big $O$ notation is appreciated as well.
Note: I am following a proof of this theorem from Nathanson's Elementary Methods in Number Theory.