Fixes issues #8145 and #8154