Fix bugs to make multi-datacenter work