fixes issues #770 and #856