Fix for #1044 #1047