A slightly different version of the fix in ada8877. Port to 0.6.