Import from 5.34 patches fixes for ROOT-5509 and ROOT-5542