Refactor get-replica-map, add debug logs