fix for issue #3090 and #3091 on master branch

Fixes #3090 
Fixes #3091