fixes issue #8145 and #8159