Fixed a potential issue with topology building