Fix occasional failure in topology building