Complete fix for #642