#6319 and #6402 were reverted before adding SAF changes, and have been readded at the end of SAF changes