D7 port of the recent D6 modifications