apply the remainder of PR#6742 here: extra fixes + ^K]