I have a question about the proof of the truncated Perron formula in my analytic number theory lecture notes.
The Formula is given as follows: Let $x,c,T>0$ and suppose that $\sum_n |a_n|/n^c$ is convergent. Then $$\sum^{'}_{n\le x} a_n = \frac{1}{2\pi i}\int_{c-iT}^{c+iT} (\sum_n \frac{a_n}{n^s}) x^s \frac{ds}{s} + O(x^c \sum \frac{|a_n|}{n^c}\min\{1, \frac{1}{T |\log (x/n)|}\}),$$ where $\sum^{'}_{n\le x}$ denotes that if $x$ is an integer then the final summand $a_x$ is replaced by $(1/2) a_x$.
The proof is supposed to follow from the result (Lemma 5.2 below) $$|\delta(x/n)-\frac{1}{2\pi i}\int_{c-iT}^{c+iT} \frac{x^s}{n^s}\frac{ds}{s}|< \frac{x^c}{n^c} \min \{1,\frac{1}{T|\log(x/n)|}\}$$ if $n\neq x$ and $< \min\{1,c/T\}$ if $n=x$. $\delta(x)$ is defined as $1/2$ if $x=1$ and $1$ if $x>1$, and the fact that we can swap summation and integration when they are absolutely convergent.
My question is in the case where $x$ is an integer then we should use the bound $\min\{1,c/T\}$ instead of $\frac{x^c}{n^c} \min \{1,\frac{1}{T|\log(x/n)|}\}$ from the result of Lemma 5.2 but why is this ignored in the big Oh term of Lemma 5.3?
It is also stated that we can actually ignore the $'$ and replace it with a regular sum because if $x$ is an integer then the big Oh term in the lemma is at least as large as $|a_x|$. But I don't understand how this makes sense because $n=x$ gives $\log(x/n)=0$ so we get $1/0$ in the big Oh term.
Finally, the proof of Lemma 5.3 states that both $\sum_{n=1}^\infty \int_{c-iT}^{c+iT}|a_n \frac{x^s}{n^s}\frac{1}{s}||ds|$ and $\int_{c-iT}^{c+iT} \sum_{n=1}^\infty |a_n \frac{x^s}{n^s}\frac{1}{s}||ds|$ are convergent since $\sum_{n=1}^\infty \frac{|a_n|}{n^c}$ converges. I am not clear how we handle the term $\frac{|x^s|}{|s|}|ds|$ here so that both are convergent. Is it because $|x^s|=x^c$ so can ignore this term, and $1/|s| |ds|$ is a straight line integral from $(c,-T)$ to $(c,T)$ so is a finite interval integral of a continuous nonzero function?
I would greatly appreciate any clarification on the proof of this theorem.

