Partial fix for #640