A simple question. In classical mechanics, the Hamiltonian is not always equal to the total energy of the system, cf. e.g. this Phys.SE post. Is this also the case in quantum mechanics, or does something 'fix' it in this case?
No, discrepancies between the Hamiltonian and the total energy in a quantum system is more or less taken over from the corresponding classical system.
The Hamiltonian in non-relativistic mechanics doesn't know about the relativistic rest energy $mc^2$ of the particles.
The Hamiltonian relative to some local reference frame doesn't know about the total energy relative to some fiducial inertial frame, cf. e.g. section 8.2 in H. Goldstein, Classical Mechanics.