Partly revert min vs. max hotfix

Using max() was bad because it made DoS possible.
Using min() is wrong because of the weight ordering.

Change-Id: Ib68149f76d71e088974507eb285270362a14424c