Merged code from CR.