fix for #1064 and #1065