Fixes #9947.  This commit creates a fair bit of duplication but I am void of any better ideas