Fix bugs with counting branch of the topology