some arithmetics and type conversion fixes.
some arithmetics and type conversion fixes.

sean-/patroni,pgexperts/patroni,jinty/patroni,jinty/patroni,sean-/patroni,zalando/patroni,pgexperts/patroni,zalando/patroni