Ported 1.2.2 changes to 1.7.2.