darwin: fix bugs in topology code