Bug Fix: Incorrect result with custom label costs.

Bug fix due to: Konrad Kucharski <konrad.kucharski@techland.pl>. Thank
you Konrad for finding the bug. Note, it is fairly difficult to trigger
this particular bug. It only shows up when labels have uneven costs and
the cost of updating a label is very high.

Signed-off-by: Tim Henderson <tim.tadh@gmail.com>