Reinstate r133513 (reverted in r133700) with an additional fix for a