Cherry picked fix for issue #48