Backport fixes from mc1.7.10