Fix issue #9781 and #9783