Better fix for 28afdd547d712b5ea1292ec724f877706669c80f

That solution doesn't work on MRI 1.8.