Fix for #663 and #614