Back ported changes from DR-117.