Fix masterless cluster

Looks good on CI.
These changes should not be forward ported to 1.7 (it already contains similar changes).
(They should be undone when forward porting 1.6 to 1.7)