Complete fix for #1019.