first full fix for #927 May still be buggy