fix for #510 & #516