Revert most of c1374ba032a06510e741f0944547dfeb655edadd

Commit c1374ba032a06510e741f0944547dfeb655edadd for some reason reverted
commits 4a44369d8ab01feb69bee0875d659fe7bd086970 and
91cbc9aff14c6290071e6d317024cd4ebf24917d.