Avoid strange negative bucket key values in certain situations (bug 12342)