backported fix for #78