fix issues #736 and #733
Suggested fix for #739