fixes issues #8159 and #8145