fix for #1070 and #1067