The Hamilton operator is often defined as $$ \hat H = \frac{-\hbar^2 }{2m}\frac{d^2}{dx^2} + V(x) $$ but shouldn't it rather be $$\begin{aligned} \hat H &= \int\int dxdx' |x\rangle \langle x|\hat H|x'\rangle \langle x'|\\ &= \int \int dx dx' |x\rangle \left[ -\frac{\hbar^2}{2m}\left(\frac{\partial}{\partial x'}\frac{\partial}{\partial x}\delta(x-x') \right) + V(x)\delta(x-x') \right ]\langle x'| \\ \hat H &= \int dx |x\rangle \left[ -\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2} + V(x) \right ]\langle x| \\ \hat H &= \int dx |x\rangle \langle x| \left[ -\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2} + V(x) \right ]\\ \hat H&=\hat 1\left[ -\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2} + V(x) \right ] \end{aligned}$$
Because it seems to me that only in this way we have
$$ \hat H |\psi\rangle = \int dx |x\rangle \left[ -\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2} + V(x) \right ]\psi(x) $$ and $$ \langle x|\hat H | \psi\rangle =\left[ -\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2} + V(x) \right ]\psi(x) $$
Am I overly pedantic or even wrong? Is the distinction between $$ \hat 1 \left[ -\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2} + V(x) \right ] = \hat H $$ and $$ \left[ -\frac{\hbar^2}{2m}\frac{\partial^2}{\partial x^2} + V(x) \right ]$$ unnecessary/unreasonable or should it be made?